virtual_pet
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| virtual_pet [2026/03/01 14:32] – [Try this GUI Runner] frchris | virtual_pet [2026/03/01 15:02] (current) – [Part C] frchris | ||
|---|---|---|---|
| Line 126: | Line 126: | ||
| </ | </ | ||
| ===== Activity 4 ===== | ===== Activity 4 ===== | ||
| + | ==== Part A: Food ==== | ||
| <file java Food.java> | <file java Food.java> | ||
| /** | /** | ||
| Line 132: | Line 132: | ||
| * @author (your name) | * @author (your name) | ||
| * @version (a version number or a date) | * @version (a version number or a date) | ||
| + | | ||
| + | * A Food object is created with parameters that define the name of the food, | ||
| + | * the increase in energy level, the increase in happiness level, | ||
| + | * and the amount of weight gained if the food is consumed by a | ||
| + | * VirtualPet object. | ||
| + | | ||
| + | * The Food class provides a constructor with the following header: | ||
| + | * public Food(String name, int energyIncrease, | ||
| + | * The Food class also has accessor methods for all instance variables. | ||
| */ | */ | ||
| public class Food | public class Food | ||
| Line 140: | Line 149: | ||
| } | } | ||
| </ | </ | ||
| + | ==== Part B: Game ==== | ||
| <file java Game.java> | <file java Game.java> | ||
| /** | /** | ||
| Line 172: | Line 181: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| Line 333: | Line 343: | ||
| } | } | ||
| </ | </ | ||
| - | ==== GUI Based Runner for Activity 4 ==== | + | ==== Part C Putting it all together ==== |
| + | |||
| + | Now that we have a Game and Food class, let’s revise the VirtualPet class to include interactions with these classes. | ||
| + | - Write the class VirtualPet4. You may copy your code implementation of VirtualPet from Activity 3 but be sure to modify the class header and constructor to match the new class name. | ||
| + | |||
| + | - Modify the '' | ||
| + | |||
| + | - Modify the '' | ||
| + | |||
| + | === GUI Based Runner for Activity 4 === | ||
| - [[https:// | - [[https:// | ||
virtual_pet.1772393574.txt.gz · Last modified: by frchris
