college/Summer-2024/CS-3443/Labs/Lab2/Assignment.org
2024-06-17 21:58:55 -05:00

6.4 KiB

Objectives: Here, you'll have the opportunity to showcase your mastery of Java syntax, ArrayLists, File I/O operations, and UML diagrams. Embrace the challenge and let your understanding shine!


Useful Resources: Arrays and ArrayLists, File IO, ArraysAndArrayLists.zip, FileIO.zip


Estimated Time: 100 minutes


Task: The United Federation of Planets needs your help organizing their fleet of interstellar starships. They're requesting software with a simple interface and Java objects to handle starships, which are spacecrafts manned by a crew. With this software, the Federation will be able to accurately track senior staff aboard each starship. Make it so!


Instructions

Begin by creating a new Java project in Eclipse, named according to the lab guidelines - project name should be “abc123-lab2”, where abc123 is your UTSA ID.

Create the following classes in the default package of your project:

  • Fleet.java
  • Starship.java
  • CrewMember.java

Your application will read in data from text files placed in a data directory. Create a new folder called data in your project (note: this new folder must not be in your src folder), and move all sample files into it.

To get you started, we've provided a test class, Lab2.java.

Download Lab2.java. Put this in your default package as well. Your final submission must include this class exactly as it appears here, and the data files given. Once your application is completed, running Lab2.java with the given data files will result in the exact output shown below. Do not change this class.

----------------------------

United Federation of Planets

----------------------------

USS Endeavour, Nebula. Registry: NCC-71805

0 crew members assigned.

USS Bozeman, Sovereign. Registry: NCC-1941-A

0 crew members assigned.

USS Enterprise, Constitution. Registry: NCC-1701-A

8 crew members assigned.

 - James T. Kirk (Captain) - Commanding Officer [Human]

 - Spock (Commander) - First Officer [Vulcan/Human]

 - Leonard McCoy (Lieutenant Commander) - Chief Medical Officer [Human]

 - Montgomery Scott (Lieutenant Commander) - Chief Engineering Officer [Human]

 - Christine Chapel (Crewman) - Nurse [Human]

 - Nyota Uhura (Lieutenant) - Communications Officer [Human]

 - Hikaru Sulu (Lieutenant) - Helmsman [Human]

 - Pavel Chekov (Ensign) - Navigator [Human]

USS Bozeman, Soyuz. Registry: NCC-1941

0 crew members assigned.

USS Enterprise, Galaxy. Registry: NCC-1701-D

8 crew members assigned.

 - Jean-Luc Picard (Captain) - Commanding Officer [Human]

 - William T. Riker (Commander) - First Officer [Human]

 - Beverly Crusher (Lieutenant Commander) - Chief Medical Officer [Human]

 - Geordi La Forge (Lieutenant) - Chief Engineering Officer [Human]

 - Deanna Troi (Lieutenant Commander) - Counselor [Betazoid]

 - Worf (Lieutenant) - Helmsman [Klingon]

 - Data (Lieutenant Commander) - Chief Operations Officer [Android]

 - Tasha Yar (Lieutenant) - Chief Security Officer [Human]

USS Gibraltar, Sovereign. Registry: NCC-75689

0 crew members assigned.

More Details

CrewMember.java

This class will represent a CrewMember object, which we will define as having:

  • A name, represented as a String (e.g. “James T. Kirk”)
  • A position, (e.g. “Commanding Officer”)
  • A rank, (e.g. “Captain”)
  • A species (e.g. “Human”)
  • An assignment (e.g. “NCC-1701-A”)
  • Two constructors - one which requires all of the above fields, and one which requires all except for the assignment.
  • A toString() method which returns a String representation of the CrewMember
  • Getters and setters for all fields

Starship.java

This class will represent a Starship object, which we will define as having:

  • A name, represented as a String (e.g. “USS Enterprise”)
  • A registry, (e.g. “NCC-1701-A”)
  • A class of starship (e.g. “Constitution”)
  • An ArrayList of CrewMember objects
  • A constructor which requires all String fields and initializes the collection
  • A toString() method which returns a String representation of the Starship
  • An addCrewMember(…) method which takes a CrewMember parameter and adds them to the starship and returns nothing
  • A getNumberOfPersonnel() method which takes no parameters and returns an Integer count of crew members on the starship
  • Getters and setters for all fields

Fleet.java

This class will represent a Fleet object, which we will define as having:

  • A name, represented as a String (e.g. “United Federation of Planets”)
  • An ArrayList of Starship objects
  • A constructor which requires all String fields and initializes the collection
  • A getSizeOfFleet() method which returns the number of starships in the fleet
  • An addStarship(..) method which takes a Starship parameter and adds it to the fleet, returning nothing.
  • A toString() method which calls upon the toString() in Starship to return a string representation of the fleet.
  • Getters and setters for all fields
  • A loadStarships(…) method which takes in a directory name and adds a Starship to the Fleet for each file found. This method should not return anything and needs to “throw” an exception in order to allow for file I/O.

UML Diagram

  • After completing the programming, create a UML diagram showing the application classes and their relationships, and add it to your Eclipse project.

Notes

  • Follow Java code style including the capitalization of your zip file, project name, and class names, and variables. (Recall that names of Java variables and methods should be in camel case)
  • All classes should have Javadoc comments.
  • The grader will test your code using different data files, in the same format as given. If coded according to the requirements of this lab, your submission will output the correct result. However, if you "hard code" any portion of the lab (except Lab2.java, which again, you should not modify) your submission will fail this test case.)

Submitting Your Lab

  • When you have finished programming, create a zip file of the project and submit it on Canvas

    • right-click on your project in Eclipse
    • Click "Export"
    • Under "General" choose "Archive File"
    • Ensure your project name is selected in the top left listing of projects (only the project you need to submit). Ensure all required files are included.
    • Under "To archive file", select a place to save your file and name your zip file (for labs, follow the abc123-labX.zip convention)
    • Upload only the zip file to Canvas (here)