OOF Assignment Part B – due: 12:00 pm Wed 23

Department of Computer Science and Information Technology

CSE1/4OOF Semester 2, 2020
Assignment Part B
Due Date: Wednesday, 23rd September 2020, at 12.00 p.m.
First and Final date for SUBMISSION Wednesday 23rd September 2020 at 12.00 pm
Delays caused by computer downtime cannot be accepted as a valid reason for a late submission.
Students must plan their work to allow for both scheduled and unscheduled downtime. There are no
days late or extensions on this assignment as execution test marking will begin on Wednesday
23rd September – in your normal lab (Week 9)
This is an individual assignment. You are not permitted to work as a group when writing
this assignment.
Copying, Plagiarism: Plagiarism is the submission of somebody else’s work in a manner that
gives the impression that the work is your own. The Department of Computer Science and
Information Technology treats academic misconduct seriously. When it is detected, penalties are
strictly imposed. Refer to the unit guide for further information and strategies you can use to avoid
a charge of academic misconduct. All submissions will be electronically checked for
plagiarism.
Submission Details: Full instructions on how to submit electronic copies of your source code
files from your latcs8 account are given at the end. If you have not been able to complete a
program that compiles and executes containing all functionality, then you should submit a
program that compiles and executes with as much functionality as you have completed. (You
may comment out code that does not compile.)
Note you must submit electronic copies of your source code files using the submit command
on latcs8. Ensure you submit all required files, one file at a time. For example, the file
Lunarnaut.java would be submitted with the command:
> submit SOF Lunarnaut.java
PLEASE NOTE: While you are free to develop the code for this progress check on any operating system,
your solution must run on the latcs8 system.
Marking Scheme: This assignment is worth 15% of your final mark in this subject.
Implementation (Execution of code) 90%, explanation of code 10%
You may be required to attend a viva voce (verbal) assessment
(to be used as a weighting factor on the final mark).
Return of Mark sheets:
The face to face execution test marking through Zoom in the lab (Week 9) constitutes a return of the
assignment mark, subject to the conditions on page 12.
Do NOT use the LMS to submit your files, use latcs8 only
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 2 of 22
I need help writing my essay – research paper note carefully:
The submit server will close at 12:00 pm on Wednesday September 23rd
After the submit server has closed, NO assignments can be accepted.
I need help writing my essay – research paper make sure that you have submitted all your assignment files before the
submit server closes. (see page 12)
There can be NO extensions or exceptions.
Your assignment will be marked in your normal lab, Wednesday September 23rd
2020.
You must attend your assigned lab (the lab you have signed up for on allocate
plus). Non-attendance will result in your assignment being awarded 0, as will
attending a lab that is not your assigned lab, without prior notification, as detailed
below.
If you cannot attend your assigned lab please email lecturer to arrange another
time.
Marking scheme:
90% for the code executing correctly
10%, you will be asked to explain (and / or alter) parts of your code.
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 3 of 22
I need help writing my essay – research paper also note carefully that whilst we encourage innovation and exploring java beyond what
has been presented in the subject to date, above all, we encourage understanding.
The assignment that follows can be solved using techniques that have been presented in
lectures, lecture / workshops and labs so far.
These are the techniques and knowledge that we will later be examining in the Real Time Test
and the exam.
Code and techniques that are outside the material presented will not be examined, of course.
You are free to implement the program below in any way, with one condition.
Any assignment that uses code that is outside what has been presented to this point must be
fully explained at the marking execution test. Not being able to fully explain code outside
what has been presented in the subject so far will result in the assignment being awarded a
mark of 0, regardless of the correctness of the program.
Submitting an assignment with code outside what has been presented so far and not attending
the marking execution test will result in an automatic mark of 0, regardless of the correctness of
the submission.
I need help writing my essay – research paper note that all object attributes must have private as their
access modifier. Any classes that have any non-private object attributes
will result in the whole assignment mark being heavily reduced, up to
and including, being awarded 0, regardless of the correctness of the
program. This includes omitting access modifiers, which means that
the object attributes have the java default access modifier package.
This is covered in Week 7 lectures.
Using code not taught in OOF – READ THIS
Access Modifiers in objects
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 4 of 22
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 is Base only
If the Lunarnaut has worked between 5 and 10 hours (inclusive),
then their skill is Ranches
If the Lunarnaut has worked between 11 and 15 hours (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.
(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 Wed 23
rd September this is the first and final hand in date Page 5 of 22
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.java and sample input files
base01.dat, base02.dat and base03.dat
Copy them from the unit library area or from assignment folder into your current directory using:
cp /home/1st/csilib/cse1oof/assignB/* .
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 that the Lunarnaut
has worked (See the explanation below)
 skill This is a String and is one of the four skills,
as described above. The skill is always based on the number 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.
The Lunarnaut class requires the following functionality:
A constructor that takes name, lunarnautId, and hours as 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 page 11
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.
don’t forget the . (dot)
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 6 of 22
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.
I need help writing my essay – research paper 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
Compartment is 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 compartmentId is the unique identifier for a Compartment.
 lunarnaut This 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 Compartment id 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
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 7 of 22
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 Lunarnaut id, 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 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 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.
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 8 of 22
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:
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 a Compartment object from the
keyboard.
If both of the Compartment object references (Compartment 1 (c1) and Compartment 2
(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 Compartment 1 is not free, then
Compartment2 (c2) is used.
How can you tell if a Compartment object reference is “free”, that is, does not have a
Compartment object attached? We have studied this 
The Lunarnaut and Compartment classes 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.
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.
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 9 of 22
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-null Compartment 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 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 Lunarnaut id is not already in use. If
the user entered Lunarnaut id 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 Lunarnaut id is unique. The user is then asked to
enter the name of the Lunarnaut and the Lunarnaut object 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. Add Mission
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
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 10 of 22
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
Compartment must 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 Compartment is 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 Compartment can be assigned a Mission, then the appropriate changes are made to the
Compartment and its associated Lunarnaut object. These are that the number of hours
worked by the Lunarnaut is 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
Compartment is 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 Add Mission, that is, there is actually at least one non-null
Compartment object reference. As with Add Mission 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 that Compartment 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 Compartment with 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.
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 11 of 22
{
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
Lunarnaut name – String
Lunarnaut id – String
Lunarnaut hours – int
An example of the information, in the text file, on each Compartment consists of 6 lines if there
is a Compartment and Lunarnaut as follows in the example below, or just 3 lines if there is
just a Compartment either way the complete 6 lines, or 3 lines, is known as a record:
DDG 82 unique Compartment id of the Compartment
false indicates the Compartment is not on a Mission
0 indicates that there is NOT a Lunarnaut object associated with
this Compartment object
CV 64 unique Compartment id of the Compartment
false indicates the Compartment is not on a Mission
1 indicates that there is a Lunarnaut object associated with this
Compartment object
OOF Lunarnaut name of the Lunarnaut
X B 19 unique id of the Lunarnaut
5 number of hours that the Lunarnaut has worked
Another example of an input file:
A 56 unique Compartment id of the Compartment
true indicates the Compartment is on a Mission
1 indicates that there is a Lunarnaut object associated with this
Compartment object
Sixth Lunarnaut name of the Lunarnaut
D 222 unique id of the Lunarnaut
6 number of hours that the Lunarnaut has worked
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
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.
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 12 of 22
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 a Lunarnaut id or a Compartment id
from the keyboard, to add a Lunarnaut or add a Compartment, the program must check that
the Lunarnaut id or Compartment 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 Lunarnaut id 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 submit command.
submit SOF Lunarnaut.java
submit SOF Compartment.java
submit SOF 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.
I need help writing my essay – research paper 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 Wed 23
rd September this is the first and final hand in date Page 13 of 22
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
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 14 of 22
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
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 15 of 22
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
I need help writing my essay – research paper 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)
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 16 of 22
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
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 17 of 22
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
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 18 of 22
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
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 19 of 22
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
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 20 of 22
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
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 21 of 22
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
OOF Assignment Part B – due: 12:00 pm Wed 23
rd September this is the first and final hand in date Page 22 of 22
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.
Final notes
Don’t let anyone look at your code and definitely don’t give anyone a copy of your code. The
plagiarism checker will pick up that the assignments are the same and you will both get 0 (it
doesn’t matter if you can explain all your code).
And a final, final note, “eat the dragon in little bits”. Do a little bit every night; before you know it, you will
be finished. The assignment is marked with running code, so you are better to have 2 or 3 parts
completed that actually compile and run, rather than a whole lot of code that doesn’t compile.
The execution test is done on latcs8 so please make sure that your code
runs on latcs8 before you submit.

Published by
Ace Tutors
View all posts