Jackiehanna1
New Member
- Joined
- Oct 28, 2014
- Messages
- 1
- Gender
- Female
- HSC
- N/A
I'm a beginner in Java and was stuck while doing this exercise. Would someone be able to help by showing me the correct java code for this task?
Define a public class Chest according to the following description.
A Chest has an integer “combination”, an integer “position” and 3 jars (“jar1”, “jar2” and “jar3”).
The constructor for class Chest should read the combination from the user according to the
following I/O:
Enter chest combination (5-10): 7
The chest should be created at position 4, and 3 empty jars should be created at the same position as
the chest itself.
Update the definition of class Ground to reflect that the ground has 1 player, 3 jars and a chest.
Before continuing, make any necessary changes to your existing code to ensure that all constructors,
methods and classes are public and all fields are private.
Define a public class Chest according to the following description.
A Chest has an integer “combination”, an integer “position” and 3 jars (“jar1”, “jar2” and “jar3”).
The constructor for class Chest should read the combination from the user according to the
following I/O:
Enter chest combination (5-10): 7
The chest should be created at position 4, and 3 empty jars should be created at the same position as
the chest itself.
Update the definition of class Ground to reflect that the ground has 1 player, 3 jars and a chest.
Before continuing, make any necessary changes to your existing code to ensure that all constructors,
methods and classes are public and all fields are private.