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
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

Joey McGee

Greenhorn
+ Follow
since Nov 22, 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 Joey McGee

Joanne Neal wrote:Your Event class is immutable (you can't change its state once you've created it. Therefore your grossPrice, discount and netPrice calculations in the toString method will always return the same value. I would therefore be inclined to do these calculations in the constructor which will only be called once rather than in the toString method where they will be calculated every time the method is called.


Not sure how to do that, any further help?
9 years ago

Joanne Neal wrote:Always try to avoid infinite loops (while(true)) with break statements in them.
makes the purpose of the code a lot clearer.


Not sure I follow... What is the . . . for in the code?
9 years ago

Joanne Neal wrote:Comments should always be accurate.

Is the comment on line 10 of your Meal class accurate ?

What about the one on line 47 of your CateringCompany class ? If you replace that break by System.exit(0) does the code behave exactly the same ?


Not sure about the comment on line 10 of my Meal class... That's why I posted this here, so I could get help putting comments in my code. My teacher loves comments.
9 years ago
I need help finishing putting comments into my program, if anyone is willing to help me with that it would be greatly appreciated as I'm not that good at it . Also please double check my coding to make sure it's all correct. It compiles and runs correctly but that doesn't always mean the coding is 100% correct as I've found out.


9 years ago
Below is the code where I've created a loop and am trying to code it to end if the user types in no... If anyone could help me with this it would be greatly appreciated.
9 years ago
Look at my message above!
9 years ago

Aj Prieto wrote:Your do-while loop could be shortened to:


For discouts, it looks like you have to associate a price for each meal code and multiply that by the amount of people that order it. With that number, you subtract the discounted amount.


Thanks... I've created a new class called Meal where I put the meals and their prices in, so I probably have to set the discounts in there some how.

If anyone would be willing to check over my code and help me add the discounts in as well as lable things that would be greatly appreciated. Also I'm stuck on how to add this new class to the main class (CateringCompany) so it will print everything out correctly.
9 years ago
Ok here is what I have so far...

CateringCompany class:

Event class:

I'm not sure how to code the discounts in or what else may need to be added to get the program running par the requirments, so if anyone could help me figure any part of the program out or if there is anything wrong with what I've coded so far please let me know.
9 years ago

James Boswell wrote:I would like to suggest writing a static method on the Event class to validate the meal code:

I will leave you with the implementation of this method which you can then use in your while loop:



That's a big help... Thanks, now all I have to do is putting the proper coding under the public static boolean isMealCodeValid(int mealCode) in the Event class. I believe I can figure that part out. Thanks again.
9 years ago

I seem not to be getting anywhere... Here is what I have now in the CateringCompany class but I'm not sure how to end the while loop.


If anyone can help me with the while loop, that would be greatly appreciated. I need the loop to not only say invalid for meal codes greater than 5 but for also less than 1 and I also need to prompt the user to type in a valid meal code, which is anything 1-5.
9 years ago

Jackson Lawton wrote:

Aj Prieto wrote:On what part are you lost?

First you have to create an instance/object with the constructor of the Event class. Then you add that object to your ArrayList.



Didn't I do that??? It compiles and runs correctly. Oh and I need the mealCode under that loop not month, my original question mentioned that, though I typed in month instead of mealCode in my coding.



Hmm, I typed in the original CateringCompany coding wrong... Here is the correct coding minus the loop:



Don't know where I got that other coding.


9 years ago

Aj Prieto wrote:On what part are you lost?

First you have to create an instance/object with the constructor of the Event class. Then you add that object to your ArrayList.



Didn't I do that??? It compiles and runs correctly. Oh and I need the mealCode under that loop not month, my original question mentioned that, though I typed in month instead of mealCode in my coding.
9 years ago

Aj Prieto wrote:Right now your adding Strings to the arraylist rather than Event. The ArrayList you created takes in Event objects.

So it'd be something like:


Also we can't comment on your event class without seeing what you have.



Ok I'm a bit lost... Here is my Event class:

9 years ago

Campbell Ritchie wrote:No, that looks nothing like 100% right. You have a List<Event> but you are not filling it with Events. You are filling it with Strings. The compiler won’t be happy about that. It won’t be happy about some other things.
Before you can create a List<Event>, you need an Event class. All the inputs like number of guests are used as attributes of the Event class, Create an Event class, with its fields, constructor and a few methods. You might do well to create a Menu class or similar for the entrées. Forget all about the List for the time being. Get one object of the Event class working first, then you can consider the List later.



I don't know what methods need to be done in the Event class but I've already created an Event class with instance variables set to private and a constructor. If anyone can help me at all create a loop (not sure what I'm doing wrong) and/or add methods in the Event class, that would be greatly appreciated.
9 years ago
I'm trying to add a loop to my program to varify the meal code and if it's not valid, continue to prompt the user until it is. The meal code goes from 1-4. Below is my code so far:



9 years ago