Reference no: EM132739388
CSE4OOF Object-Oriented Programming Fundamentals - La Trobe University
Problem Background
The time has come to establish a permanent base on Moon. If this is successful, then it will be expanded into a much larger base. As this is just the very beginning of the development, it has been decided to restrict the problem to just 2 Compartments.
A Compartment is an all-purpose building that allows humans to work on Moon.
The people who go to Moon are known as Lunarnauts.
The Lunarnauts carry out Missions. Missions vary and have a number of hours assigned to them.
The default is one Mission = one hour.
Missions are also graded into one of 4 skills, with each succeeding skill being more difficult and requiring more experience (more hours). This is explained below.
Each Compartment must have a Lunarnaut assigned to the Compartment before it can be assigned a Mission and the Compartment must not already be on a Mission. When the Compartment is on a Mission, it is assumed that the Mission is always completed.
It is not possible to have a Lunarnaut without there being a Compartment first. It is possible to have a Compartment without a Lunarnaut.
When a Compartment is first created, it is added to the Moon Base. This means, of course, that when a Compartment is first added, it has no Lunarnaut, it is not on a Mission and its hours are 0.
As the Lunarnaut carries out more Missions, their skill increases, as they are accumulating more hours.
If the Lunarnaut has worked between 0 and 4hours (inclusive),
then their skill is Base only
If the Lunarnaut has worked between 5 and 10hours (inclusive),
then their skill is Ranches
If the Lunarnaut has worked between 11 and15hours (inclusive),
then their skill is Life Aid
If the Lunarnaut has worked 16, or more, hours,
then their skill is Moon rover
To be assigned a Mission, firstly, the Compartment must have a Lunarnaut and not be on a Mission.
Secondly the skill required for the Mission must be within the skill of the Lunarnaut. A Lunarnaut with a higher skill can undertake a Mission that requires a lesser skill, but a Lunarnaut cannot undertake a Mission that requires a higher skill.
The Lunarnaut must have the required skill before being assigned the Mission. As soon as the Compartment (and associated Lunarnaut) is assigned a Mission, the user is asked to enter the number of hours for that Mission.
Program Requirements
You have been asked to write an interactive program, in Java, to aid in monitoring and maintaining all aspects of Moon Base Operations.
This program is a prototype and there will be only 2 Compartment objects in the program. If the prototype proves successful, this will be expanded in the next assignment.
To aid in the rapid development of this program, 3 Java files and 3sample input files are provided for you:
Lunarnaut.java, Compartment.java, MoonBase.java and sample input filesbase01.dat, base02.dat and base03.dat
Copy them from the unit library area or from assignment folder into your current directory using:
In order to further speed up the development of this program, some of the files listed above have been partially implemented for you, read the comments in the files and in this document.
Lunarnaut.java
All Lunarnaut objects have the following object attributes:
• name This a String (text) and is the name of the Lunarnaut, may be more
than one word
• lunarnautId This a String (text) and is the unique id of the Lunarnaut, may be
more than one word
• hours This is an integer and is the number of hours thatthe Lunarnaut
has worked(See the explanation below)
• skill This is a String and is one of the four skills,
as describedabove. The skillis always based on thenumber of
hours that the Lunarnauthas worked and must be set by the program.
The user must NEVER be able to enter the skill,nor is it ever stored in a file.
The Lunarnaut class requires the following functionality:
A constructor that takes name, lunarnautId, and hoursas parameters. This is the constructor that is called when a new Lunarnaut is added from the text file. From the file, all three of these parameters have values.
The format of the text file is shown on page11
Recall that it is the number of hours that determine the skill, so there has to be a way for the constructor to set the skill. If this constructor is also used for keyboard input, then the number of hours must be set to 0 as the Lunarnaut has just been created.
Alternatively, you could write an overloaded constructor that just takes the first two values (name and lunarnautId) as parameters and assigns 0 to the number of hours.
Either way, the skill must be set by the constructor, not the user.
This is where you write a private helper method in the Lunarnaut class, similar to the setCategory method in lab 7
The Lunarnaut class also requires accessor methods as you deem appropriate.
The Lunarnaut class also requires a method to increment the number of hours. Calling this method adds more hours to the total number of hours. This method should then check whether that moves the Lunarnaut to the next skill.
Recall that the default is one hour for a new Mission and the user must be asked if there are more hours associated with this Mission. The user must be able to press the enter key if there are no extra hours associated with the Mission. Actually entering 0 will lose marks. (Hint: think about the way we extracted integers from Strings in Assignment A or the length of an empty String)
If there are extra hours, then these extra hours plus the default one hour are added to the total number of hours for the Lunarnaut (with the required next skill check)
Finally, the Lunarnaut class requires a toString method which returns a String with information about the Lunarnaut object, see page 15 for the format of the String to be returned.
Please note that the output must follow the format exactly, this will be assigned marks in the execution test.
Compartment.java
The Compartment class has the following attributes:
• onMission This is a boolean variable, the value false indicates that the
Compartmentis NOT on a Mission. The value true indicates that the
Compartment is on a Mission.
• compartmentId This is a String (text) and may consist of more than one word
The compartmentIdis the unique identifier for a Compartment.
• lunarnautThis is the Lunarnaut class object reference for the lunarnaut object that
is associated with this Compartment
(when the Lunarnaut object is added and instantiated)
The Compartment class requires 2 overloaded constructors.
The first overloaded constructor takes just the Compartmentid for a Compartment object. This constructor is called when adding a Compartment object from the keyboard. The Compartment cannot be on a Mission as it has just been created and, for the same reason, it cannot have a Lunarnaut object associated with it.
The second overloaded constructor is for creating a Compartment object from the input text file. In the text file there will be the Compartment id, number of hours worked and a boolean value to indicate whether or not the Compartment is currently on a Mission. There will also always be an integer, either 0 or 1, directly after the boolean value. If this has the value 1, then it indicates there is information for the Lunarnaut object associated with this Compartment. This will consist of the Lunarnaut's Lunarnautid, name and the number of hours that they have worked. If the integer is 0, then there is no Lunarnaut associated with this Compartment. See page11 for the file format.
The Compartment class must never have a Lunarnaut object reference as a parameter in any of its methods, including the constructor(s).Reading from the file, if there is a Lunarnaut associated with the Compartment, then the Lunarnaut's name, id and the number of hours they have worked will have been read out and can be passed to a Compartment constructor that takes these parameters, as well as the Compartment parameters.
Alternatively, there can just be one overloaded constructor for the Compartment class that takes just the Compartment information and a separate method can be called to add the Lunarnaut to that Compartment. Up to you which one you choose; both are valid ways of solving this part of the problem.
The Compartment class will require accessor methods as you deem appropriate.
The Compartment class also requires a toString method that returns a String with information about the state of that Compartment object. The format of the String is shown in the example output on page 15. As with the Lunarnaut screen output, you must follow the format shown exactly, marks will be assigned to following the format.
The Compartment class requires a method to add a Lunarnaut to the Compartment. This method takes all of the relevant parameters for instantiating a Lunarnaut object(but doesn't pass in a Lunarnaut object reference). The resultant object is stored in the Lunarnaut object reference. Each Compartment can have only one Lunarnaut. When adding from the keyboard, the program needs to check that the Compartment object does not already have a Lunarnaut object. This method is called when the user adds a Lunarnaut from the keyboard or from the file.
The Compartment also needs methods to start and end a Mission. Recall that when all the conditions are met and a Mission is assigned to a Compartment, the number of hours for the associated Lunarnaut has to be incremented, which can include extra hours for the Lunarnaut. Starting a Mission sets the on Mission attribute of the Compartment to true and ending a Mission sets this attribute to false.
The skill attribute is private to the Lunarnaut class, so it cannot be called directly from the Compartment class. All interactions (message passing) between the Compartment and Lunarnaut classes must be through the public methods of the Lunarnaut class.
If the skill attribute can be set directly from the Compartment class, or any other attributes of the Lunarnaut class can be directly access from the Compartment class, the whole assignment will be awarded 0, regardless of the functionality of the program.
The Compartment class could also use a method that takes the required skill of the Mission as a parameter and returns true or false as to whether the associated Lunarnaut has the required skill. Note that this is could also be done in the main driver class, MoonBase, which is described below.
You might find it useful to write a method in the Compartment class that returns a boolean to indicate if the Compartment already has a Lunarnaut or not.
The driver program, MoonBase.java starts by presenting the user with a menu, as follows:
MoonBase Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>
Implement the functionality of each menu choiceas follows (assume user input is always an integer):
1. Add Compartment
This menu option is chosen when the user attempts to add a Compartment object from the keyboard.
If both of the Compartment object references (Compartment1(c1)and Compartment2 (c2)) already have Compartment objects, then the user is informed via a message to the screen and the program returns to the main menu without asking the user for any information.
If at least one of the Compartment object references does not have a Compartment object, then the user is asked to enter the Compartment id of a Compartment.
The program must check that this Compartment id is not already assigned to a Compartment. If the Compartment id is already assigned to another Compartment, the user is informed via a message to the screen and the program returns to the main menu. If the user entered Compartment id is unique, then the appropriate Compartment constructor is called and a new Compartment object is instantiated.
NO Lunarnaut information is entered in this menu choice.
If both Compartment object references are free (do not have Compartment objects attached to them), then Compartment1 (c1) is always used first. If Compartment1 is not free, then Compartment2(c2) is used.
How can you tell if aCompartment object reference is "free", that is, does not have aCompartment object attached? We have studied this ?
Regardless of the action taken in this menu choice, the program returns to the main menu when this menu choice is completed.
2. Display
This menu choice displays the contents of the non-nullCompartment object references to the screen. The format is shown in the sample run of the program on page 15. If both Compartment object references are null then an appropriate message is displayed to the screen.
Calling this menu choice must not result in the program crashing (for example, NullPointerException)
3. Add Lunarnaut to Compartment
This menu choice adds a Lunarnaut to a Compartment, using information from the keyboard. First, of course, the program must check that there is actually a Compartment to which we can add a Lunarnaut, If there are no Compartment objects, then the user is informed with a message to the screen and the program returns to the main menu. The user is not asked for any further information.
If there is at least one Compartment object, then the user is asked for the Compartment id of a Compartment.
The program tries to find the Compartment with this Compartment id.
If the Compartment with the user entered Compartment id is found, then there is one further check. This is to check that Compartment does not already have a Lunarnaut object. If there is already a Lunarnaut object, then the user is informed via a message to the screen, no further information is asked from the user, and the program returns to the main menu.
If the Compartment with the user entered Compartment id is found and it does not have a Lunarnaut object, then the user is asked to enter the id of a Lunarnaut. There is one final check. The program must check that this user entered Lunarnautid is not already in use. If the user entered Lunarnautid is already in use, then the user is informed via a message to the screen, no further information is requested from the user, and the program returns to the main menu.
If the program gets to this point, then there is a Compartment object with the user entered Compartment id and the user entered Lunarnautid is unique. The user is then asked to enter the name of the Lunarnaut and the Lunarnautobject is added to that Compartment object. (The number of hours must be 0, as we have just instantiated the Lunarnaut and the skill is worked out by the Lunarnaut constructor, based on the number of hours).
If there is not a Compartment with the user entered Compartment id, then a message is displayed to the screen and the program returns to the main menu, without asking for any more information.
4. AddMission
This menu choice first checks that there is at least one non-null Compartment object reference. If both Compartment object references are null, then an appropriate message is displayed to the screen and the program returns to the main menu. If there is at least one non-null Compartment object reference, then the user is prompted (asked) for the Compartment id of a Compartment.
The program must then find the Compartment that contains the Compartment object with this Compartment id. This could be the first Compartment object or the second Compartment object (if it exists). If the Compartment id is not found, then an appropriate message is displayed to the screen and the program returns to the main menu.
If the Compartment id is found, then the program must check that this Compartment is available for a Mission.
To be available for a Mission, the Compartment must not on a Mission (working) and the Compartmentmust have a Lunarnaut. That is, the Lunarnaut object reference in the Compartment object in which the Compartment with the user entered Compartment id was found, must have a Lunarnaut object attached to it.
If the Compartmentis not available for a Mission, then an appropriate message is displayed to the screen and the program returns to the main menu.
After passing the checks above, the user is asked to enter the required skill of the Mission. If the Lunarnaut has the required skill, then and only then is the Compartment assigned that Mission.
If the Compartmentcan be assigned a Mission, then the appropriate changes are made to the Compartmentand its associated Lunarnautobject. These are that the number of hoursworked by the Lunarnautis incremented (do not forget to check whether this crosses one of the boundaries of the skills, resulting in a change in skill) and the on Mission attribute of the Compartmentis set to true, indicating that the Compartment is on a Mission.
The program always returns to the main menu at the end of the menu choice, regardless of the action taken or not taken.
5. End Mission
This menu choice prompts (asks) the user for the Compartment id of a Compartment, after making the same checks as in AddMission, that is, there is actually at least one non-null Compartment object reference. As with AddMission appropriate messages should be displayed to the screen if the Compartment with the user entered Compartment id is not found, there are no non-null Compartment object references or if the Compartment id is found but thatCompartment is not already on a Mission. (You can't end a Mission unless the Compartment is currently on a Mission.)
If any of the above are true, then the program returns to the main menu.
If the Compartmentwith the user entered Compartment id exists and the Compartment is on a Mission, then the onMission attribute is set to false, indicating that the Compartment is not on a Mission.
After the conclusion of any and all actions in this menu choice, the program returns to the main menu.
6. Load from file
The user is prompted for the name of an input text file. You may assume that this file always exists and is correctly formatted. The input file will hold at least one Compartment record (A record is shown in the table below), your program may assume that the user never enters a file name that exists but is empty.
The program must work with any file name entered by the user (of the correct format), that is, the file name must not be hard coded.
Consider that you may open an input text file with 3 records in it and the user has already entered information from the keyboard for one Compartment object. In that case the first record would be read from the input text file and assigned to the second Compartment object reference. After this the file could be closed or you could keep reading through the text file, but any further records would be discarded, they would not overwrite the information for existing Compartment objects.
The format of the file is:
Compartment Id- String
onMission- boolean
int- 0 means no Lunarnaut, 1 means a Lunarnaut
Lunarnautname - String
Lunarnautid - String
Lunarnauthours - int
In both the examples, the first 2 lines are required to instantiate the Compartment object reference in the Compartment object, the third line indicates whether, or not, there is a Lunarnaut object to read and the next 3 lines are required to instantiate the Lunarnaut object reference in the same Compartment object, if there is a Lunarnaut object.
The file may contain any number of records.
As a final note, consider that when the user enters aLunarnautid or aCompartment id from the keyboard, to add a Lunarnaut or add a Compartment, the program must check that the LunarnautidorCompartment id are not already in use. If they are, then the user is informed with an appropriate message to the screen and the method returns to the main menu.
Lunarnaut id's and Compartment id's in the input file are guaranteed to be unique and you may assume that the user will not enter a Lunarnautid or a Compartment id from the keyboard that is already in the input text file, even though you have not read the text file. Your program does NOT need to check for this.
The user can select this add from input file option at any time whilst the program is running, it does not have to be at the start.
7. Exit the program
This menu choice closes the program.
Electronic Submission of the Source Code
• Submit all the Java files that you have developed in the Missions above.
• The code has to run under Unix on the latcs8 machine.
• You submit your files from your latcs8 account. Make sure you are in the same directory as the files you are submitting. Submit each file separately using the submitcommand.
submit OOF Lunarnaut.java
submit OOF Compartment.java
submit OOF MoonBase.java
After submitting the files, you can run the following command that lists the files submitted from your account:
verify
You can submit the same filename as many times as you like before the assignment deadline; the previously submitted copy will be replaced by the latest one.
Note: in the above requirements, where it talks about Compartment id's and Lunarnaut id's being unique, this applies on a case insensitive basis.
That is, k 45 h and K 45 H are to be treated as exactly the same id.
Please make sure that you have read page 2 about the submission close off date and time and the compulsory requirement to attend the execution test during Week 9
Failure to do both of these things will result in your assignment be awarded a mark of 0, regardless of the correctness of the program.
Execution test marks are provisional and subject to final plagiarism checks and checks on the compliance of your code to this assignment document.
As such final assignment marks may be lower or withdrawn completely.
Example run of the program (NOTE not all functionality and error checks/messages are shown)
user input in bold
>java MoonBase
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>2
No Compartments added yet, nothing to display
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>3
No Compartments present, cannot add Lunarnaut
until at least one Compartment has been constructed
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>4
No Compartments in the Base
So no Lunarnauts yet
Create at least one Compartment and assign at least one Lunarnaut before adding Missions!
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>5
No Compartments in the base no Missions to end
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>1
Enter Compartment id >>k 45 H
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>2
Here is the information for the Compartments
Compartment[ id: k 45 H
Currently is not on a Mission
No Lunarnaut assigned to this Compartment
]
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>3
Enter Compartment id >>E 56
No Compartment with that id was found
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>1
Enter Compartment id >>k 45 h
Compartment id's must be unique
That Compartment id is already in use
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>3
Enter Compartment id >>k 45 h
Enter Lunarnaut id >>D 001
Enter Lunarnaut name >>Moon 01 Person
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>2
Here is the information for the Compartments
Compartment[ id: k 45 H
Currently is not on a Mission
Lunarnaut [ name : Moon 01 Person
id : D 001 hours : 0
skill: Base only
]
]
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>6
Enter file name >>b.dat
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>2
Here is the information for the Compartments
Compartment[ id: k 45 H
Currently is not on a Mission
Lunarnaut [ name : Moon 01 Person
id : D 001 hours : 0
skill : Base only
]
]
Compartment[ id: O C 27
Currently is on a Mission
Lunarnaut [ name : Third Person
id : B 03 hours : 12
skill : Life Aid
]
]
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>5
Enter Compartment id >>k 45 h
That Compartment is not on a Mission
so cannot end a Mission
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>5
Enter Compartment id >>O C 27
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>2
Here is the information for the Compartments
Compartment[ id: k 45 H
Currently is not on a Mission
Lunarnaut [ name : Moon 01 Person
id : D 001 hours : 0
cap : Base only
]
]
Compartment[ id: O C 27
Currently is not on a Mission
Lunarnaut [ name : Third Person
id : B 03 hours : 12
cap : Life Aid
]
]
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>1
The base is full, no free Compartment spaces
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>4
Enter Compartment id >>K 45 H
Enter Mission level >>Moon rover
The Lunarnaut in this Compartment does not have the required level of experience
for this Mission
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >> 4
Enter Compartment id >>K 45 H
Enter Mission level >>base only
Enter extra hours default is 0, just press the enter key for 0,
or enter extra hours >>(enter key was pressed here)
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >> 2
Here is the information for the Compartments
Compartment[ id: k 45 H
Currently is on a Mission
Lunarnaut [ name : Moon 01 Person
id : D 001 hours : 1
cap : Base only
]
]
Compartment[ id: O C 27
Currently is not on a Mission
Lunarnaut [ name : Third Person
id : B 03 hours : 12
cap : Life Aid
]
]
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>4
Enter Compartment id >>O C 27
Enter Mission level >>ranches
Enter extra hours default is 0, just press the enter key for 0,
or enter extra hours >>16
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>2
Here is the information for the Compartments
Compartment[ id: k 45 H
Currently is on a Mission
Lunarnaut [ name : Moon 01 Person
id : D 001 hours : 1
cap : Base only
]
]
Compartment[ id: O C 27
Currently is on a Mission
Lunarnaut [ name : Third Person
id : B 03 hours : 29
cap : Moon rover
]
]
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>4
Enter Compartment id >>k 45 h
This Compartment is already on a Mission, cannot add another Mission
till current Mission is completed
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>5
Enter Compartment id >> K 45 H
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>2
Here is the information for the Compartments
Compartment[ id: k 45 H
Currently is not on a Mission
Lunarnaut [ name : Moon 01 Person
id : D 001 hours : 1
cap : Base only
]
]
Compartment[ id: O C 27
Currently is on a Mission
Lunarnaut [ name : Third Person
id : B 03 hours : 29
cap : Moon rover
]
]
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>3
All Compartments already have Lunarnauts
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>7
Good bye from Moon Base
Another run of the program
>java MoonBase
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>1
Enter Compartment id >>K 45 H
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>3
Enter Compartment id >>k 45 H
Enter Lunarnaut id >>K 002
Enter Lunarnaut name >>Moon 03 Person
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>3
Enter Compartment id >>K 45 h
This Compartment already has a Lunarnaut
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>1
Enter Compartment id >>CV 64
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>2
Here is the information for the Compartments
Compartment[ id: K 45 H
Currently is not on a Mission
Lunarnaut [ name : Moon 03 Person
id : K 002 hours : 0
cap : Base only
]
]
Compartment[ id: CV 64
Currently is not on a Mission
No Lunarnaut assigned to this Compartment
]
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>3
Enter Compartment id >>CV 64
Enter Lunarnaut id >>K 002
Lunarnaut id's must be unique
That Lunarnaut id is already in use
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>4
Enter Compartment id >>CV 64
This Compartment does not have a Lunarnaut, so cannot be assigned a Mission
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>6
The base is full, cannot add more Compartments
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>4
Enter Compartment id >>k 45 h
Enter Mission level >>base only
Enter extra hours default is 0, just press the enter key for 0,
or enter extra hours >>10
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>2
Here is the information for the Compartments
Compartment[ id: K 45 H
Currently is on a Mission
Lunarnaut [ name : Moon 03 Person
id : K 002 hours : 11
cap : Life Aid
]
]
Compartment[ id: CV 64
Currently is not on a Mission
No Lunarnaut assigned to this Compartment
]
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>5
Enter Compartment id >>CV 64
That Compartment is not on a Mission
so cannot end a Mission
Moon Base Main Menu
1. Add Compartment
2. Display Compartments
3. Add Lunarnaut to Compartment
4. Add Mission
5. End Mission
6. Load from file
7. Exit the program
Enter choice >>7
Good bye from Moon Base
It is essential that your code displays to the screen the outcome of the actions that you have coded. Without this display, we have no way of checking that your assignment is in fact meeting the requirements.
The smallest amount of code that compiles, runs and displays an outcome will get more marks than a whole assignment that does not compile, does not run or does not display anything to the screen.
Attachment:- Object-Oriented Programming Fundamentals.rar