Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

Kevin Thien

Greenhorn
+ Follow
since Aug 12, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kevin Thien

Cause that's all we've learnt in class, basically.
9 years ago
Hi guys, I've set up my GUI via FlowLayout and used boxes to set up my UI as needed for an assignment. The issue is that the code looks really messy, and I'd like to break it down further to reduce mess and allow for changes in the future.



Is there a way to change that big bulk to just something like:
top();
info();

?
9 years ago
Been a while since I've posted back but I've got most of my things to work. Currently I'm trying to get a check done for the time a user inputs and validating with my array of times. Currently I'm getting my array to be null and I can't figure out why.



The source and destination are definitely being picked up cause I can see them in my S.o.P debug, but they won't initialise my times array properly. I'm racking my brain on this right now and I can't figure it out.

*EDIT I'm an idiot with strings. Fixed it with a stupid way.



Now my issue is with


How do I make it not print "Not available" for each instance of the array it checks?
9 years ago
We were actually given a design flow for his model solution which actually gave me the most confusion. The client chart flow was:

Airline has Routes and Customers. Routes have route. Route has Days. Days have Pods. Customers have Customer. Customer has Trip. Trip has routes and a Flight. Flight has a route.



What I don't really get is why it's passing down route as a variable. I can code the S.o.p and corresponding variable input, S.o.p("Destination"); destination = In.nextLine(); as well as the validity checks.
9 years ago
I'm not looking for direct answers, but rather help in getting onto the right direction in regards to what I'm doing. My assignment is a text-based airline booking ticket. I'll past all the code given and that I've coded so far and explain my thought processes. There's a few things I'm totally confused about right now and would LOVE some help in understanding what I should be doing next.











I've coded the beginning menu which is fine. The next part I was going to code was the main booking option. The way our teacher has set out this model code is that we're suppose to pass attributes down from route > day > pod and the route itself is passed to the customer and it's flight. We were told to create all the possible flight routes in constructor of the Day class (Why, this I don't really understand).

The current part I'm stuck on is implementing the choice "b" to book. Example IO given to us is along the lines of:


While getting the S.o.p is simple, I'm unsure of how I'm suppose to be passing these attributes down as the switch code for booking is:

I don't really understanding why the base code we were given to work off of passes routes down as the variable when we want to begin booking.
9 years ago
The issue isn't the input not being read, but rather I think my LinkedList matching code being wrong.



All the examples we were giving were doing with int but I presumed it'd work for String as well, but that seems to not be the case, and I'm lost as to why.

EDIT: Solved it cause I'm an idiot and didn't update the customer.matches();


Thanks to the help above for the .equals() for strings!
9 years ago
Thanks, that fixed the sentinel value issue! However, whenever I enter any other value for the ID, it's still returning a null match (presumably) as "No such customer" keeps being printed.
9 years ago
Hi, this week in class we're working with LinkedLists and while my program runs when I use user ID as an int, my sentinel value "000" ends the program whenever an ID of "0", "00" or "000" is entered. I realised that 0 = 00 = 000, so to fix that I changed the ID from int value to string value. Now however, my code doesn't recognise any input and always outputs "No such customer".









I'm sure the issue I'm having is super simple. Also, if there's anything that I could do to fix/clean-up the code as I'm still learning Java. If possible, please explain why you do certain things so I can learn instead of just copy/pasting solutions, thanks!
9 years ago

Winston Gutkowski wrote:

Kevin Thien wrote:I just found it easier to code the reverse method because it was a single line of code.



Don't re-invent the wheel. It may be trite, but its true.

Winston



Yup, that's what our teacher says too. If it already exists, use it. No point in writing complicated lines of code if a single method can do everything for you!
9 years ago
Wow, thanks for all the responses guys, learnt a lot! While this was academic, we were allowed free-roam so to say as to how the actual palindrome check worked. So we could've done it via array, or reverse. I just found it easier to code the reverse method because it was a single line of code.
9 years ago
Ah yeah, I had that idea too, but I was hoping for a "cleaner" way to do it I guess without an extra IF statement. The IN class is within my package so that's okay, thanks for the answer though!
9 years ago


Currently the code works perfectly fine in telling me whether an entered string is a palindrome or not, however, when I use my sentinel-string "end", the program will end but it will print out "no" which isn't really needed. I'm sure I'm missing something super simple but I can't figure it out for the life of me (yet).
9 years ago