CSE1OOF/4OOF | Good Grade Guarantee!
As human kind expands into space, there is a requirement for building cities in space.
. These modules can be outfitted for different purposes.
Modules, and the city as a whole, require power. This power comes from solar panels attached to the Modules. As all Modules have the same dimensions, all Modules can fit a maximum of 6 solar panels, 3 on each of sides A and B (as per assignment Part C). Each solar panel generates 5.25 units of power.
Each Module has a unique identification, known as an ident. This always begins with an uppercase character, which must be one of ‘A’, ‘C’, ‘E’, ‘F’, ‘I’, ‘P’, or ‘S’, any other starting character is invalid and should be rejected.
There may be any number of digits after this initial character.
The first character of the ident also determines the type of the Module, as follows:
Building on earlier work, each Module may now have a number of Crew Members. The exact maximum number depends on the type of the Module, as follows:
possible to change the id of a Crew Member once it has been set.
a valid starting character for a Crew Member id.
Crew Member id’s are unique.
OOF Progress Check Test – due: 10:00 am Mon 25th May this is the first and final hand in date Page 3 of 20
Crew Members may be moved from one Module to another Module, provided that they are allowed to move to that Module (based on the restriction above) and there is room in the destination Module. Remember that any Crew Member may be moved into a Module of type Crew Quarters, regardless of their id (again provided there is space in that Module).
The Space City is expanding, there is now a maximum of 100 Modules in a Space City, although at the very start of building there are no Modules in the Space City.
By now you should know how to create a subdirectory for this assignment, create that subdirectory now and change into that subdirectory.
You have been asked to write an interactive program, in Java, to aid in the construction and management of a Space City.
To aid in the rapid development of this program, 3 Java files and an example input file are provided for you:
CrewMember.java, Module.java, SpaceCity.java and a sample input file mod10.dat
Note that CrewMember.java for you.
Copy them from the unit library area into your current directory (which will be your newly created subdirectory) using:
cp /home/1st/csilib/cse1oof/prog/* .
Failure to create a subdirectory and cd into it will result in your java files from Assignment Part C being overwritten by the files for this assignment.
Task 1 – Module.java
Design and implement the Module class (by completing Module.java) so that we can create and use a Module object.
The Module class requires a constructor that takes one attribute, ident. This constructor is for constructing a Module object with keyboard input.
The Module class requires a method, called from the constructor, that sets the type (see the table on page 3), based on the ident.
OOF Progress Check Test – due: 10:00 am Mon 25th May this is the first and final hand in date Page 4 of 20
The Module class also requires a method, also called from the constructor, that sets the capacity (see the table on page 3), based on the type.
Once the capacity is known, then the crew array is instantiated, other attributes are set to their default values.
The Module class also requires another constructor that takes as parameters, all of the attributes, except the CrewMember array. This constructor is called when constructing a Module object from reading inputs from a text file. Remember that the array of CrewMembers still needs to be instantiated.
The Module class requires a method to add a CrewMember. This method must first check that there is space in the array of CrewMembers, if there is, then the CrewMember object reference is assigned to the next free index in the crew array and the current attribute is incremented. You may want to overload this method so that the Module class can add a CrewMember by passing the name and id of a CrewMember as parameters and also an overloaded version that takes as a parameter an existing CrewMember object reference.
The Module class needs accessor methods and a toString method that returns all the details of a Module object, including any CrewMember objects in the crew array.
The Module class also needs a method that will return the details of the CrewMember array, remember to ensure that there are no privacy leaks.
The Module class will also require a method that removes a CrewMember from the CrewMember array. This method takes as a parameter the index in the CrewMember array of the CrewMember to be removed. How the program finds this index is something for SpaceCity.java. This method returns the removed CrewMember (again, ensure that there are no privacy leaks). This method must also check that the index passed in as the parameter is valid. Finally this method must ensure that the CrewMember array does not have any null entries between CrewMember object references. This requires that when a CrewMember is removed at a certain index, all the remaining CrewMember objects are moved down one index and the current attribute is decreased by 1.
Additional methods that you may want to add to the Module class include a method that takes as a parameter a PrintWriter object reference. This method would be very useful when the Module class is to be written to an output text file. Another method that might be useful is a method that returns, as a String, information about the Module, without any CrewMember information.
As in Assignment Part C, the Module class requires a method to add a panel to a Module, this follows the same rules as in Assignment Part C.
As in Assignment Part C, the Module class does not take keyboard input inside the class.
Task 2 – SpaceCity.java
The driver program, SpaceCity.java has as an object attribute, an array of Modules. This is of size 100 which is thus the maximum number of Modules that can be in the Space City.
This object attribute and a number of final (constant) attributes are already declared in the class.
OOF Progress Check Test – due: 10:00 am Mon 25th May this is the first and final hand in date Page 5 of 20
The program starts by asking the user for the name of text file. This text file, described below, contains all the information to create Module and CrewMember objects that are stored in the array. The name of the text file must not be hard coded. You may assume that the name of the text file the user enters will always exist and that the file is not empty.
Information on each Module consists of at least 6 lines as follows (and is known as a record) and as many lines as are needed for the CrewMembers already in this Module. Recall that a CrewMember record consists of two lines, the name and id.
(so the number of extra lines may be 0 to any number):
QUALITY: 100% ORIGINAL – NO PLAGIARISM.
- **REMEMBER TO PRECISE PAGE NUMBER**
- Hit The Order Button To Order A **Custom Paper**