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


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 4 hours (inclusive), then their skill isBase only


If the Lunarnaut has worked between 5 and 10 hours (inclusive), then their skill isRanches


If the Lunarnaut has worked between 11 and 15 hours (inclusive), then their skill isLife Aid


If the Lunarnaut has worked 16, or more, hours, then their skill isMoon 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 skillbeforebeing 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.


(Just pressing the enter key means that the Mission has the default number of hours, that is, just 1)


OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in datePage4of22


Note that adding more hours to the total number of hours for that Lunarnaut may move the Lunarnaut up into the next skill, this has to be checked.
To end a Mission, the Compartment must actually be on a 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 3 sample input files are provided for you:


Lunarnaut.java,Compartment.java,MoonBase.javaand sample input filesbase01.dat,base02.datandbase03.dat


Copy them from the unit library area or from assignment folder into your current directory using:


/home/student/csilib/cse1oof/2020/BU2/A2/* .


don't forget the . (dot)


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 filesand in this document.


Lunarnaut.java


All Lunarnaut objects have the following object attributes:


•nameThisaString(text)andisthenameoftheLunarnaut,maybemore than one word


•lunarnautIdThis a String (text) and is theuniqueid of the Lunarnaut, may be more than one word


•hours•skill


The Lunarnaut class requires the following functionality:


A constructor that takesname,lunarnautId, andhoursas parameters. This is the constructor that is called when a newLunarnautis added from the text file. From the file, all three of these parameters have values.


The format of the text file is shown on page 11


Recall that it is the number ofhoursthat determine theskill, so there has to be a way for the constructor to set theskill. If this constructor is also used for keyboard input, then the number ofhoursmust be set to 0 as theLunarnauthas just been created.


This is an integer and is the number of hours that the Lunarnaut
has worked (See the explanation below)
This is a String and is one of the four skills,
as described above. The skill is always based on thenumber of
hours that the Lunarnaut has 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.


OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in datePage5of22


Alternatively, you could write an overloaded constructor that just takes the first two values (nameandlunarnautId) as parameters and assigns 0 to the number ofhours.
Either way, theskillmust be set by the constructor, not the user.


This is where you write a private helper method in theLunarnautclass, similar to thesetCategorymethod in lab 7


TheLunarnautclass also requires accessor methods as you deem appropriate.


TheLunarnautclass also requires a method to increment the number ofhours. Calling this method adds more hours to the total number ofhours. This method should then check whether that moves theLunarnautto 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 hoursplusthe default one hour are added to the total number of hours for the Lunarnaut (with the required next skill check)


Finally, theLunarnautclass requires atoStringmethod which returns aStringwith information about theLunarnautobject, see page 15 for the format of theStringto 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:


•onMissionThisisabooleanvariable,thevaluefalseindicatesthattheCompartmentis NOT on a Mission. The valuetrueindicates that the


Compartmentis on a Mission.
•compartmentIdThisisaString(text)andmayconsistofmorethanoneword


ThecompartmentIdis theuniqueidentifier for aCompartment.


•lunarnautThisistheLunarnautclassobjectreferenceforthelunarnautobjectthat is associated with thisCompartment


(when theLunarnautobject is added and instantiated) TheCompartmentclass requires 2 overloaded constructors.


The first overloaded constructor takes just theCompartment idfor aCompartmentobject. This constructor is called when adding aCompartmentobject from the keyboard. TheCompartmentcannot be on a Mission as it has just been created and, for the same reason, it cannot have aLunarnautobject associated with it.


The second overloaded constructor is for creating aCompartmentobject from the input text file. In the text file there will be theCompartment id, number ofhoursworked and a
OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in datePage6of22


booleanvalue to indicate whether or not theCompartmentis currently on a Mission. There will also always be an integer, either 0 or 1, directly after thebooleanvalue. If this has the value 1, then it indicates there is information for theLunarnautobject associated with thisCompartment. This will consist of the Lunarnaut'sLunarnaut id,nameand the number ofhoursthat they have worked. If the integer is 0, then there is noLunarnautassociated with thisCompartment. See page 11 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 aLunarnautassociated with theCompartment, then theLunarnaut's name,idand the number ofhoursthey have worked will have been read out and can be passed to aCompartmentconstructor that takes these parameters, as well as theCompartmentparameters.


Alternatively, there can just be one overloaded constructor for theCompartmentclass that takes just theCompartmentinformation and a separate method can be called to add theLunarnautto thatCompartment. Up to you which one you choose; both are valid ways of solving this part of the problem.


TheCompartmentclass will require accessor methods as you deem appropriate.


TheCompartmentclass also requires atoStringmethod that returns aStringwith information about the state of thatCompartmentobject. The format of theStringis shown in the example output on page 15. As with theLunarnautscreen output,you must follow the format shown exactly, marks will be assigned to following the format.


TheCompartmentclass requires a method to add aLunarnautto theCompartment. This method takes all of the relevant parameters for instantiating aLunarnautobject(but doesn't pass in a Lunarnaut object reference). The resultant object is stored in theLunarnautobject 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 aLunarnautfrom the keyboard or from the file.


TheCompartmentalso needs methods to start and end a Mission. Recall that when all the conditions are met and a Mission is assigned to aCompartment, the number ofhoursfor the associatedLunarnauthas to be incremented, which can include extra hours for theLunarnaut. Starting a Mission sets theon Missionattribute of theCompartmenttotrueand ending a Mission sets this attribute tofalse.


Theskillattribute isprivateto theLunarnautclass, so it cannot be called directly from theCompartmentclass. All interactions (message passing) between theCompartmentandLunarnautclasses must be through thepublicmethods of theLunarnautclass.


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.


TheCompartmentclass could also use a method that takes the requiredskillof the Mission as a parameter and returnstrueorfalseas to whether the associatedLunarnauthas the requiredskill. Note that this is could also be done in the main driver class,MoonBase, which is described below.


OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in datePage7of22


You might find it useful to write a method in theCompartmentclass that returns abooleanto indicate if theCompartmentalready has aLunarnautor not.


TheLunarnautandCompartmentclasses do NOT ask the user for any input, either keyboard or file. There must not be any input objects in these classes such as Scanner or BufferedReader but not limited to these 2. Another way of saying this is that these classes are not interactive.


The driver program,MoonBase.javastarts by presenting the user with a menu, as follows:


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



Implement the functionality of each menu choice as follows (assume user input is always an integer):


1. Add Compartment


This menu option is chosen when the user attempts to add aCompartmentobject from the keyboard.
If both of theCompartmentobject references (Compartment 1 (c1)andCompartment 2 (c2)) already haveCompartmentobjects, then the user is informed via a message to the screenand the program returns to the main menu without asking the user for any information.


If at least one of theCompartmentobject references does not have aCompartmentobject, then the user is asked to enter theCompartment idof aCompartment.


The program must check that thisCompartment idis not already assigned to aCompartment. If theCompartment idis already assigned to anotherCompartment, the user is informed via


a message to the screen and the program returns to the main menu. If the user enteredCompartment idis unique, then the appropriateCompartmentconstructor is called and a newCompartmentobject is instantiated.


NO Lunarnaut information is entered in this menu choice.


If bothCompartmentobject references are free (do not haveCompartmentobjects attached to them), thenCompartment1 (c1) is always used first.IfCompartment 1is not free, thenCompartment2(c2) is used.


How can you tell if aCompartmentobject reference is "free", that is, does not have aCompartmentobject attached? We have studied this
OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in datePage8of22


Note: MoonBase class must NOT have Lunarnaut object attribute(s) or Lunarnaut object references. All interactions involving a Lunarnaut will be through the relevant Module object.


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 thenon-nullCompartmentobject references to the screen. The format is shown in the sample run of the program on page 15. If bothCompartmentobject references arenullthen 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 aLunarnautto aCompartment, using information from the keyboard. First, of course, the program must check that there is actually aCompartmentto which we can add aLunarnaut, If there are noCompartmentobjects, 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 oneCompartmentobject, then the user is asked for theCompartment idof aCompartment.
The program tries to find theCompartmentwith thisCompartment id.


If theCompartmentwith the user enteredCompartment idis found, then there is one further check. This is to check that thatCompartmentdoes not already have aLunarnautobject. If there is already aLunarnautobject, 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 theCompartmentwith the user enteredCompartment idis found and it does not have aLunarnautobject, then the user is asked to enter theidof aLunarnaut. There is one final check. The program must check that this user enteredLunarnaut idis not already in use. If the user enteredLunarnaut idis 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 aCompartmentobject with the user enteredCompartment idand the user enteredLunarnaut idis unique. The user is then asked to enter thenameof theLunarnautand theLunarnautobject is added to thatCompartmentobject. (The number ofhoursmust be 0, as we have just instantiated theLunarnautand theskillis worked out by theLunarnautconstructor, based on the number ofhours).


If there is not aCompartmentwith the user enteredCompartment id, then a message is displayed to the screen and the program returns to the main menu,without asking for any more information.


4. Add Mission


This menu choice first checks that there is at least one non-nullCompartmentobject reference. If bothCompartmentobject references arenull, 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


OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in datePage9of22


Compartmentobject reference, then the user is prompted (asked) for theCompartment idof aCompartment.


The program must then find theCompartmentthat contains theCompartmentobject with thisCompartment id. This could be the firstCompartmentobject or the secondCompartmentobject (if it exists). If theCompartment idis not found, then an appropriate message is displayed to the screen and the program returns to the main menu.


If theCompartment idis found, then the program must check that thisCompartmentis available for a Mission.


To be available for a Mission, theCompartmentmust not on a Mission (working)andtheCompartmentmusthave aLunarnaut. That is, theLunarnautobject reference in theCompartmentobject in which theCompartmentwith the user enteredCompartment idwas found, must have aLunarnautobject attached to it.


If theCompartmentis 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 requiredskillof the Mission. If theLunarnauthas the requiredskill, then and only then is theCompartmentassigned that Mission.


If theCompartmentcan be assigned a Mission, then the appropriate changes are made to theCompartmentand its associatedLunarnautobject. These are that the number ofhoursworked by theLunarnautis incremented (do not forget to check whether this crosses one of the boundaries of theskills, resulting in a change inskill) and theon Missionattribute of theCompartmentis set totrue, indicating that theCompartmentis 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 theCompartment idof aCompartment, after making the same checks as inAdd Mission, that is, there is actually at least one non-nullCompartmentobject reference. As withAdd Missionappropriate messages should be displayed to the screen if theCompartmentwith the user enteredCompartment idis not found, there are no non-nullCompartmentobject references or if theCompartment idis found but thatCompartmentisnot already on a Mission. (You can't end a Mission unless theCompartmentis currently on a Mission.)


If any of the above aretrue,then the program returns to the main menu.


If theCompartmentwith the user enteredCompartment idexists and theCompartmentis on a Mission, then theonMissionattribute is set tofalse, indicating that theCompartmentis not on aMission.


After the conclusion of any and all actions in this menu choice, the program returns to the main menu.


OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in datePage10of22


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 oneCompartmentrecord (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 oneCompartmentobject. In that case the first record would be read from the input text file and assigned to the secondCompartmentobject 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 existingCompartmentobjects.


The format of the file is:
Compartment Id-String
onMission-boolean
int- 0{means no Lunarnaut, 1 means a LunarnautLunarnaut name-String
Lunarnaut id-String
Lunarnaut hours-int


An example of the information, in the text file, on eachCompartmentconsists of 6 lines if there is aCompartmentandLunarnautas follows in the example below,or just 3 lines if there is just a Compartmenteither way the complete 6 lines, or 3 lines, is known as arecord:


Only if the int on the line above is 1, otherwise it is either the end of file or the start of the next Module.


DDG 82 false 0


CV 64 false 1


OOF Lunarnaut X B 19 5

uniqueCompartment id of the Compartment
indicates the Compartment is not on a Mission
indicates that there is NOT a Lunarnaut object associated with this Compartment object
uniqueCompartment id of the Compartment
indicates the Compartment is not on a Mission
indicates that there is a Lunarnaut object associated with this Compartment object
name of the Lunarnaut
uniqueid of the Lunarnaut
number of hours that the Lunarnaut has worked


Another example of an input file:


A 56 true 1


Sixth Lunarnaut D 222 6

uniqueCompartment id of the Compartment
indicates the Compartment is on a Mission
indicates that there is a Lunarnaut object associated with this Compartment object
name of the Lunarnaut
uniqueid of the Lunarnaut
number of hours that the Lunarnaut has worked


In both the examples, the first 2 lines are required to instantiate theCompartmentobject reference in theCompartmentobject, the third line indicates whether, or not, there is a


OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in datePage11of22


Lunarnautobject to read and the next 3 lines are required to instantiate theLunarnautobject reference in the sameCompartmentobject, if there is aLunarnautobject.


The file may contain any number of records.


As a final note, consider that when the user enters aLunarnaut idor aCompartment idfrom the keyboard,to add a Lunarnaut or add a Compartment, the program must check that theLunarnaut idorCompartment idare 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'sandCompartment id'sin the input file are guaranteed to be unique and you may assume that the user will not enter aLunarnaut idor aCompartment idfrom the


keyboard that is already in the input text file, even though you have not read the text file. Yourprogram 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 thesubmitcommand.


    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 handK 45 Hare 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.
    OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in datePage12of22




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 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
OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in date


and assign at least one Lunarnaut before adding

Page13of22


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


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


found


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


OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in date


Page14of22


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 Compartment[ id: k 45 H


the Compartments



Currently is not on a Mission Lunarnaut [ name : Moon 01 Person

id :D001 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 >>6Enter 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 :D001 hours:0



skill : Base only ]


] Compartment[ id: O C 27

Please note: it is a marking requirement that the format of the Compartment and the Lunarnaut display is exactly as shown in this example run. (With the exception of the hours, the position of which will depend on the size of the id)


]


Currently is on a Mission Lunarnaut [ name : Third Person


id :B03 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


OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in date


Page15of22


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 :D001 hours:0



cap : Base only ]

] Compartment[ id: O C 27


Currently is not on a Mission Lunarnaut [ name : Third Person

]


id :B03 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


OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in date


Page16of22


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 Compartment[ id: k 45 H

for the Compartments


Currently is on a Mission Lunarnaut [ name : Moon 01 Person

id :D001 hours:1



cap : Base only ]

] Compartment[ id: O C 27


Currently is not on a Mission Lunarnaut [ name : Third Person

]


id :B03 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


OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in date


Page17of22


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 :D001 hours:1



cap : Base only ]

] Compartment[ id: O C 27


Currently is on a Mission Lunarnaut [ name : Third Person

]


id :B03 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


OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in date


Page18of22


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 :D001 hours:1



cap : Base only ]

] Compartment[ id: O C 27


Currently is on a Mission Lunarnaut [ name : Third Person

]


id :B03 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 >>7Good 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


OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in date


Page19of22


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


OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in date


Page20of22


5. End Mission
6. Load from file 7. Exit the program


Enter choice >>3
Enter Compartment id >>CV 64Enter 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

OOF Assignment Part B - due: 12:00 pm Tues 22ndSeptember this is the first and final hand in date


Page21of22


Currently is on a Mission         Lunarnaut [ name : Moon 03 Person

id :K002 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 >>7Good bye from Moon Base

Sep 07, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here