Problem Background

The time has come to establish a permanent base on Mars. 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 Modules.

A Module is an all-purpose building that allows the first humans to live and work on Mars.

The people who go to Mars are known as Marsnaut's.

The Marsnaut's carry out Tasks. Tasks vary and have a number of hours assigned to them. The default is one Task = one hour.

Tasks are also graded into one of 4 capabilities, with each succeeding capability being more difficult and requiring more experience (more hours). This is explained below.

Each Module must have a Marsnaut assigned to the Module before it can be assigned a Task and the Module must not already be on a Task. When the Module is on a Task, it is assumed that the Task is always completed.

It is not possible to have a Marsnaut without there being a Module first. It is possible to have a Module without a Marsnaut.

When a Module is first created, it is added to the Mars Base. This means, of course, that when a Module is first added, it has no Marsnaut, it is not on a Task and its hours are 0.

As the Marsnaut carries out more Tasks, their capability increases, as they are accumulating more hours.

If the Marsnaut has worked between 0 and 5 hours (inclusive), then their capability is Base only
If the Marsnaut has worked between 6 and 12 hours (inclusive), then their capability is Farms
If the Marsnaut has worked between 13 and 19 hours (inclusive), then their capability is Life Support
If the Marsnaut has worked 20, or more, hours, then their capability is Mars rover

To be assigned a Task, firstly, the Module must have a Marsnaut and not be on a Task.

Secondly the capability required for the Task must be within the capability of the Marsnaut. A Marsnaut with a higher capability can undertake a Task that requires a lesser capability, but a Marsnaut cannot undertake a Task that requires a higher capability.

The Marsnaut must have the required capability before being assigned the Task. As soon as the Module (and associated Marsnaut) is assigned a Task, the user is asked to enter the number of hours for that Task.

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

Note that adding more hours to the total number of hours for that Marsnaut may move the Marsnaut up into the next capability, this has to be checked.

To end a Task, the Module must actually be on a Task.

Program Requirements

You have been asked to write an interactive program, in Java, to aid in monitoring and maintaining all aspects of Mars Base Operations.

This program is a prototype and there will be only 2 Module objects in the program. If the prototype proves successful, this will be expanded in the next iteration (The Progress Check Test assignment)

Recall that a Module object also has an associated Marsnaut object (when the Marsnaut object is assigned).

To aid in the rapid development of this program, 3 Java files and 3 sample input files are provided for you:

Marsnaut.java, Module.java, MarsBase.java and sample input files base01.dat, base02.dat and base03.dat

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

cp /home/1st/csilib/cse1oof/assignC/*

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.

Marsnaut.java

All Marsnaut objects have the following object attributes:

  • name This a String (text) and is the name of the Marsnaut, may be more than one word
  • Marsnaut id This a String (text) and is the unique id of the Marsnaut, may be more than one word
  • hours This is an integer and is the number of hours that the Marsnaut has worked.(See the explanation below)
  • capability This is a String and is one of the four capabilities, as described above. The capability is always based on the number of hours that the Marsnaut has worked and must be set by the program. The user must NEVER be able to enter the capability, nor is it ever stored in a file.

The Marsnaut class requires the following functionality:

A constructor that takes name, Marsnaut id, and hours as parameters. This is the constructor that is called when a new Marsnaut is added from the text file. From the file, all three of these parameters have values.

Recall that it is the number of hours that determine the capability, so there has to be a way for the constructor to set the capability. If this constructor is also used for keyboard input, then the number of hours must be set to 0 as the Marsnaut has just been created.

Alternatively, you could write an overloaded constructor that just takes the first two values (name and Marsnaut id) as parameters and assigns 0 to the number of hours. Either way, the capability must be set by the constructor, not the user.

This is where you write a private helper method in the Marsnaut class, similar to the setCategory method in lab 7

The Marsnaut class also requires accessor methods as you deem appropriate.

The Marsnaut 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 Marsnaut to the next capability.

Recall that the default is one hour for a new Task and the user must be asked if there are more hours associated with this Task. The user must be able to press the enter key if there are no extra hours associated with the Task. 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 Marsnaut (with the required next capability check)

Finally the Marsnaut class requires a toString method which returns a String with information about the Marsnaut 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.

Module.java

The Module class has the following attributes:

  • on Task This is a boolean variable, the value false indicates that the Module is NOT on a Task. The value true indicates that the Module is on a Task.
  • Module id This is a String (text) and may consist of more than one word The Module id is the unique identifier for a Module.
  • marsnaut This is the Marsnaut class object reference for the Marsnaut object that is associated with this Module (when the Marsnaut object is added and instantiated)

The Module class requires 2 overloaded constructors.

The first overloaded constructor takes just the Module id for a Module object. This constructor is called when adding a Module object from the keyboard. The Module cannot be on a Task as it has just been created and, for the same reason, it cannot have a Marsnaut object associated with it.

The second overloaded constructor is for creating a Module object from the input text file. In the text file there will be the Module id, number of hours worked and a boolean value to indicate whether or not the Module is currently on a Task. 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 Marsnaut object associated with this Module. This will consist of the Marsnaut's Marsnaut id, name and the number of hours that they have worked. If the integer is 0, then there is no Marsnaut associated with this Module. See page 11 for the file format.

The Module class must never have a Marsnaut object reference as a parameter in any of its methods, including the constructor(s). Reading from the file, if there is a Marsnaut associated with the Module, then the Marsnaut's name, id and the number of hours they have worked will have been read out and can be passed to a Module constructor that takes these parameters, as well as the Module parameters.

Alternatively, there can just be one overloaded constructor for the Module class that takes just the Module information and a separate method can be called to add the Marsnaut to that Module. Up to you which one you choose, both are valid ways of solving this part of the problem.

The Module class will require accessor methods as you deem appropriate.

The Module class also requires a toString method that returns a String with information about the state of that Module object. The format of the String is shown in the example output on page 15. As with the Marsnaut screen output, you must follow the format shown exactly, marks will be assigned to following the format.

The Module class requires a method to add a Marsnaut to the Module. This method takes all of the relevant parameters for instantiating a Marsnaut object (but doesn't pass in a Marsnaut object reference). The resultant object is stored in the Marsnaut object reference. Each Module can have only one Marsnaut. When adding from the keyboard, the program needs to check that the Module object does not already have a Marsnaut object. This method is called when the user adds a Marsnaut from the keyboard or from the file.

The Module also needs methods to start and end a Task. Recall that when all the conditions are met and a Task is assigned to a Module, the number of hours for the associated Marsnaut has to be incremented, which can include extra hours for the Marsnaut. Starting a Task sets the on Task attribute of the Module to true and ending a Task sets this attribute to false.

The capability attribute is private to the Marsnaut class, so it cannot be called directly from the Module class. All interactions (message passing) between the Module and Marsnaut classes must be through the public methods of the Marsnaut class.

If the capability attribute can be set directly from the Module class, or any other attributes of the Marsnaut class can be directly access from the Module class, the whole assignment will be awarded 0, regardless of the functionality of the program.

The Module class could also use a method that takes the required capability of the Task as a parameter and returns true or false as to whether the associated Marsnaut has the required capability. Note that this is could also be done in the main driver class, MarsBase, which is described below.

You might find it useful to write a method in the Module class that returns a boolean to indicate if the Module already has a Marsnaut or not.

The Marsnaut and Module 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.

The driver program, MarsBase.java starts by presenting the user with a menu, as follows:

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >>
Note: MarsBase class must NOT have Marsnaut object attribute(s) or Marsnaut object references. All interactions involving a Marsnaut will be through the relevant Module object.

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

1. Add Module

This menu option is chosen when the user attempts to add a Module object from the keyboard. If both of the Module object references (Module 1 (m1) and Module 2 (m2)) already have Module 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 Module object references does not have a Module object, then the user is asked to enter the Module id of a Module.

The program must check that this Module id is not already assigned to a Module. If the Module id is already assigned to another Module, the user is informed via a message to the screen and the program returns to the main menu. If the user entered Module id is unique, then the appropriate Module constructor is called and a new Module object is instantiated.

NO Marsnaut information is entered in this menu choice.

If both Module object references are free (do not have Module objects attached to them), then Module1 (m1) is always used first. If Module 1 is not free, then Module2 (m2) is used.

How can you tell if a Module object reference is "free", that is, does not have a Module 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-null Module object references to the screen. The format is shown in the sample run of the program on page 15. If both Module 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 Marsnaut to Module

This menu choice adds a Marsnaut to a Module, using information from the keyboard. First, of course, the program must check that there is actually a Module to which we can add a Marsnaut, If there are no Modules (that is, there are no Module 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 Module object, then the user is asked for the Module id of a Module. The program tries to find the Module with this Module id.

If the Module with the user entered Module id is found, then there is one further check. This is to check that that Module does not already have a Marsnaut object. Recall that there can only be one Marsnaut object in a Module object. If there is already a Marsnaut 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 Module with the user entered Module id is found and it does not have a Marsnaut object, then the user is asked to enter the id of a Marsnaut. There is one final check. The program must check that this user entered Marsnaut id is not already in use. If the user entered Marsnaut 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 Module object with the user entered Module id and the user entered Marsnaut id is unique. The user is then asked to enter the name of the Marsnaut and the Marsnaut object is added to that Module object. (The number of hours must be 0, as we have just instantiated the Marsnaut and the capability is worked out by the Marsnaut constructor, based on the number of hours).

If there is not a Module with the user entered Module 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 Task

This menu choice first checks that there is at least one non-null Module object reference. If both Module 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 Module object reference, then the user is prompted (asked) for the Module id of a Module.

The program must then find the Module that contains the Module object with this Module id. This could be the first Module object or the second Module object (if it exists). If the Module id is not found, then an appropriate message is displayed to the screen and the program returns to the main menu.

If the Module id is found, then the program must check that this Module is available for a Task.

To be available for a Task, the Module must not on a Task (working) and the Module must have a Marsnaut. That is, the Marsnaut object reference in the Module object in which the Module with the user entered Module id was found, must have a Marsnaut object attached to it.

If the Module is not available for a Task, 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 capability of the Task. If the Marsnaut has the required capability, then and only then is the Module assigned that Task.

If the Module can be assigned a Task, then the appropriate changes are made to the Module and its associated Marsnaut object. These are that the number of hours worked by the Marsnaut is incremented (do not forget to check whether this crosses one of the boundaries of the capabilities, resulting in a change in capability) and the on Task attribute of the Module is set to true, indicating that the Module is on a Task.

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 Task

This menu choice prompts (asks) the user for the Module id of a Module, after making the same checks as in Add Task, that is, there is actually at least one non-null Module object reference. As with Add Task appropriate messages should be displayed to the screen if the Module with the user entered Module id is not found, there are no non-null Module object references or if the Module id is found but that Module is not already on a Task. (You can't end a Task unless the Module is currently on a Task.)

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

If the Module with the user entered Module id exists and the Module is on a Task, then the on Task attribute is set to false, indicating that the Module is not on a Task.

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 Module 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 Module object. In that case the first record would be read from the input text file and assigned to the second Module 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 Module objects.

The format of the file is:

Module Id - String
onTask - boolean
int - 0 means no Marsnaut, 1 means a Marsnaut
Marsnaut name - String
Marsnaut id - String
Marsnaut hours - int

An example of the information, in the text file, on each Module consists of 6 lines if there is a Module and Marsnaut as follows in the example below, or just 3 lines if there is just a Module either way the complete 6 lines, or 3 lines, is known as a record:

DDG 82 unique Module id of the Module
false indicates the Module is not on a Task
0 indicates that there is NOT a Marsnaut object associated with this
Module object
CV 64 unique Module id of the Module
false indicates the Module is not on a Task
1 indicates that there is a Marsnaut object associated with this
Module object
OOF Marsnaut name of the Marsnaut
X B 19 unique id of the Marsnau
5 number of hours that the Marsnaut has worked

Another example of an input file:

A 56 unique Module id of the Module
true indicates the Module is on a Task
1 indicates that there is a Marsnaut object associated with this
Module object
Sixth Marsnaut name of the Marsnaut
D 222 unique id of the Marsnaut
6 number of hours that the Marsnaut has worked

In both the examples, the first 2 lines are required to instantiate the Module object reference in the Module object, the third line indicates whether, or not, there is a Marsnaut object to read and the next 3 lines are required to instantiate the Marsnaut object reference in the same Module object, if there is a Marsnaut object.

The file may contain any number of records.

As a final note, consider that when the user enters a Marsnaut id or a Module id from the keyboard, to add a Marsnaut or add a Module, the program must check that the Marsnaut id or Module 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.

Marsnaut id's and Module id's in the input file are guaranteed to be unique and you may assume that the user will not enter a Marsnaut id or a Module 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.

Example run of the program (NOTE not all functionality and error checks/messages are shown)

> java MarsBase
Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 2

No Modules added yet, nothing to display
Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 3

No Modules present, cannot add Marsnaut
until at least one Module has been constructed

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 4
No modules in the Base
So no Marsnauts yet
Create at least one Module and assign at least one Marsnaut before adding tasks!

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 5
No Modules in the base no tasks to end
Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 1
Enter module id >> k 45 H

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 2

Here is the information for the Modules

Module[ id: k 45 H
Currently is not on a Task
No Marsnaut assigned to this Module
]

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 3
Enter module id >> E 56

No module with that id was found

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 1
Enter module id >> k 45 h

Module id's must be unique
That module id is already in use

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 3
Enter module id >> k 45 h
Enter Marsnaut id >> D 001
Enter Marsnaut name >> Mars 01 Person

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 2

Here is the information for the Modules

Module[ id: k 45 H
Currently is not on a Task
Marsnaut [ name : Mars 01 Person
id : D 001 hours : 0
cap : Base only
]
]

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 6
Enter file name >> b.dat

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 2

Here is the information for the Modules

Module[ id: k 45 H
Currently is not on a Task
Marsnaut [ name : Mars 01 Person
id : D 001 hours : 0
cap : Base only
]
]
Module[ id: O C 27
Currently is on a Task
Marsnaut [ name : Third Person
id : B 03 hours : 12
cap : Farms
]
]

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 5
Enter Module id >> k 45 h

That Module is not on a Task
so cannot end a Task

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 5
Enter Module id >> O C 27

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 2

Here is the information for the Modules

Module[ id: k 45 H
Currently is not on a Task
Marsnaut [ name : Mars 01 Person
id : D 001 hours : 0
cap : Base only
]
]
Module[ id: O C 27
Currently is not on a Task
Marsnaut [ name : Third Person
id : B 03 hours : 12
cap : Farms
]
]

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 1

The base is full, no free Module spaces

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 4
Enter module id >> K 45 H

Enter task level >> mars rover

The Marsnaut in this Module does not have the required level of experience
for this task

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 4
Enter module id >> K 45 H

Enter task 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)

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 2

Here is the information for the Modules

Module[ id: k 45 H
Currently is on a Task
Marsnaut [ name : Mars 01 Person
id : D 001 hours : 1
cap : Base only
]
]
Module[ id: O C 27
Currently is not on a Task
Marsnaut [ name : Third Person
id : B 03 hours : 12
cap : Farms
]
]

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 4
Enter module id >> O C 27

Enter task level >> farms
Enter extra hours default is 0, just press the enter key for 0,
or enter extra hours >> 16

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 2

Here is the information for the Modules

Module[ id: k 45 H
Currently is on a Task
Marsnaut [ name : Mars 01 Person
id : D 001 hours : 1
cap : Base only
]
]
Module[ id: O C 27
Currently is on a Task
Marsnaut [ name : Third Person
id : B 03 hours : 29
cap : Mars rover
]
]

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 4
Enter module id >> k 45 h

This Module is already on a task, cannot add another task
till current task is completed

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 5
Enter Module id >> K 45 H

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 2

Here is the information for the Modules

Module[ id: k 45 H
Currently is not on a Task
Marsnaut [ name : Mars 01 Person
id : D 001 hours : 1
cap : Base only
]
]
Module[ id: O C 27
Currently is on a Task
Marsnaut [ name : Third Person
id : B 03 hours : 29
cap : Mars rover
]
]

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 3

All modules already have Marsnauts

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 7

Good bye from Mars Base

Another run of the program

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 1
Enter module id >> K 45 H

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 3
Enter module id >> k 45 H
Enter Marsnaut id >> K 002
Enter Marsnaut name >> Mars 03 Person

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 3
Enter module id >> K 45 h

This module already has a Marsnaut

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 1
Enter module id >> CV 64

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 2

Here is the information for the Modules

Module[ id: K 45 H
Currently is not on a Task
Marsnaut [ name : Mars 03 Person
id : K 002 hours : 0
cap : Base only
]
]
Module[ id: CV 64
Currently is not on a Task
No Marsnaut assigned to this Module
]

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 3
Enter module id >> CV 64
Enter Marsnaut id >> K 002

Marsnaut id's must be unique
That Marsnaut id is already in use

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 4
Enter module id >> CV 64

This Module does not have a Marsnaut, so cannot be assigned a task

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 6

The base is full, cannot add more Modules

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 4
Enter module id >> k 45 h

Enter task level >> base only
Enter extra hours default is 0, just press the enter key for 0,
or enter extra hours >> 10

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 2

Here is the information for the Modules

Module[ id: K 45 H
Currently is on a Task
Marsnaut [ name : Mars 03 Person
id : K 002 hours : 11
cap : Farms
]
]
Module[ id: CV 64
Currently is not on a Task
No Marsnaut assigned to this Module
]

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 5
Enter Module id >> CV 64

That Module is not on a Task
so cannot end a Task

Mars Base Main Menu
1. Add Module
2. Display Modules
3. Add Marsnaut to Module
4. Add Task
5. End Task
6. Load from file
7. Exit the program
Enter choice >> 7

Good bye from Mars Base
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.