ITEC 120 LAB 12 Back to Lab index page

Lunchcard, continued.

When you wrote your swipe method for Lunchcard, did you check to see if the lunchcard had meals to be swiped? Modify your swipe methods so that meals cannot go negative. If the client tries to swipe a meal, and there are none available, print a message to the screen that says no meals available. If the client tries to swipe 7 meals (for instance), but there are only 3 meals left, take the 3 meals and print "Only 3 meals available", and decrement the meals counter to 0.

Now add a new method public void combineMeals( Lunchcard other) which will combine the meals from two lunchcards onto the first lunchcard, and zero out the second lunchcard
(the parameter lunchcard).

Add appropriate method calls to your calling program to test your new swipe methods an your combineMeals method.

Once you have your program working, show your lab to the Peer Instructor to be checked off.