Question: JAVA PROGRAMMING -Problem Background: Human kind is pushing out into space. New planets are being discovered and explored with a view to colonizing suitable planets.
JAVA PROGRAMMING
-Problem Background:
Human kind is pushing out into space. New planets are being discovered and explored with a view to colonizing suitable planets. The agency tasked with this somewhat momentous job is the Organization Of Finders, also referred to by its better known acronym, OOF. OOF is staffed by intrepid personnel known as Crew. Crew use vehicles known as Ferries to travel from their Base Ship, which is a space ship, down to a planet and back up to the space ship. When a Crew member first joins OOF, they have not been part of any missions, their skill level is recruit. A Crew member is also referred as a Crew. As a Crew member carries out more missions, their skill level increases. If the Crew has been on between 0 and 6 missions (inclusive), then their skill level is Recruit If the Crew has been on between 7 and 8 missions (inclusive), then their skill level is Trained If the Crew has been on between 9 and 14 missions (inclusive), then their skill level is Experienced If the Crew has been on 15, or more, missions, then their skill level is Expert To be assigned a mission, firstly, the Ferry must have a Crew and not be on a mission. Secondly, the skill level required for the mission must be within the skill level of the Crew. A Crew with a higher skill level can undertake a mission that requires a lesser skill level, but a Crew cannot undertake a mission that requires a higher skill level. The Crew must have the required skill level before being assigned the mission. Each time a Crew is assigned a mission, the number of missions they have been on is incremented by one. The program must then check if the Crew has accumulated enough missions to move to the next skill level. To end a mission, the Ferry 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 Base Ship operations for OOF. This program is a prototype and there will be only 2 Ferry 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 Ferry object also has an associated Crew object (when the Crew object is assigned).
- Crew.java :
All Crew objects have the following object attributes:
1- name This a String (text) and is the name of the Crew, may be more than one word
2- Crew id This a String (text) and is the unique id of the Crew, may be more than one word
3- missions This is an integer and is the number of missions that the Crew has participated in.(See the explanation below)
4- skill level This is a String and is one of the four skill levels, as described above. The skill level is always based on the number of missions that the Crew has participated in, and must be set by the program. The user must NEVER be able to enter the skill level, nor is it ever stored in a file. The skill level is also known as the task level. Any references to task level in this document are the same as skill level. The Crew class requires the following functionality: A constructor that takes name, Crew id, and missions as parameters. This is the constructor that is called when a new Crew is added from the text file. From the file, all three of these parameters have values. Recall that it is the number of missions that determines the skill level, so there has to be a way for the constructor to set the skill level. If this constructor is also used for keyboard input, then the number of missions must be set to 0 as the Crew has just been created. Alternatively, you could write an overloaded constructor, just for use with the keyboard, this just takes the first two values (name and Crew id) as parameters and assigns 0 to the number of missions. Either way, the skill level must be set by the constructor, not the user. This is where you write a private helper method in the Crew class. The Crew class also requires accessor methods as you deem appropriate. The Crew class also requires a method to increment the number of missions. Calling this method adds another mission to the total number of missions. This method should then check whether that moves the Crew to the next skill level. Finally, the Crew class requires a toString method which returns a String with information about the Crew object. Please note that the output must follow the format exactly, this will be assigned marks in the execution test.
- Ferry.java:
The Ferry class has the following attributes:
1- ferry id This is a String (text) and may consist of more than one word The Ferry id is the unique identifier for a Ferry.
2- on mission This is a boolean variable, the value false indicates that the Ferry is NOT on a mission. The value true indicates that the Ferry is on a mission.
3- crew This is the Crew class object reference for the Crew object that is associated with this Ferry (when the Crew object is added and instantiated) The Ferry class requires 2 overloaded constructors. The first overloaded constructor takes just the Ferry id for a Ferry object. This constructor is called when adding a Ferry object from the keyboard. The Ferry cannot be on a mission as it has just been created and, for the same reason, it cannot have a Crew object associated with it. The second overloaded constructor is for creating a Ferry object from the input text file. In the text file there will be the Ferry id, number of missions worked and a boolean value to indicate whether or not the Ferry is currently on a mission. There will also always be another boolean, directly after this on mission boolean value. If this has the value true, then it indicates there is information for the Crew object associated with this Ferry. This will consist of the Crew's Crew id, name and the number of missions that they have worked. If the boolean is false, then there is no Crew associated with this Ferry. The Ferry class must never have a Crew object reference as a parameter in any of its methods, including the constructor(s). Even when reading from the file, if there is a Crew associated with the Ferry, then the Crew's name, id and the number of missions they have worked will have been read out after the Ferry object is created. Then that Ferry's addCrew method will be called. The addCrew method will take all three Crew parameters. The Ferry class will require accessor methods as you deem appropriate. The Ferry class also requires a toString method that returns a String with information about the state of that Ferry object. As with the Crew screen output, you must follow the format shown exactly. The Ferry class requires a method to add a Crew to the Ferry. (This was discussed above) This method takes all of the relevant parameters for instantiating a Crew object (but doesn't pass in a Crew object reference). The resultant object is stored in the Crew object reference. Each Ferry can have only one Crew. When adding from the keyboard, the program needs to check that the Ferry object does not already have a Crew object. This method is called when the user attempts to add a Crew from the keyboard or from the file. The Ferry also needs methods to start and end a mission. Recall that when all the conditions are met and a mission is assigned to a Ferry, the number of missions for the associated Crew has to be incremented. Starting a mission sets the on mission attribute of the Ferry to true and ending a mission sets this attribute to false. The skill level attribute is private to the Crew class, so it cannot be called directly from the Ferry class. All interactions (message passing) between the Ferry and Crew classes must be through the public methods of the Crew class. If the skill level attribute can be set directly from the Ferry class, or any other attributes of the Crew class can be directly access from the Ferry class, the whole assignment will be awarded 0, regardless of the functionality of the program. The Ferry class could also use a method that takes the required skill level of the mission as a parameter and returns true or false as to whether the associated Crew has the required skill level. Note that this is could also be done in the main driver class, SpaceShip, which is described below. You might find it useful to write a method in the Ferry class that returns a boolean to indicate if the Ferry already has a Crew or not, and another one to indicate if the Ferry is on a mission or not.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
