CS 3443 : Lab 1


Task: The Federation needs you!

The United Federation of Planets needs your help organizing their fleet of interstellar spacecrafts. Version 1.0 of their software will create 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!

Getting Started

Create a new project in Eclipse, following the lab guidelines. Create the following new Java classes, in the default package: (Use these names exactly!)


Place the following code as the main method in Fleet.java

public static void main( String[] args ) {
Fleet federation = new Fleet( "United Federation of Planets" );
Starship enterpriseA = new Starship( "USS Enterprise", "NCC-1701-A", "Constitution" );
Starship enterpriseD = new Starship( "USS Enterprise", "NCC-1701-D", "Galaxy" );

CrewMember jamesKirk = new CrewMember( "James T. Kirk", "Commanding Officer" );
CrewMember spock = new CrewMember( "Spock", "First Officer" );
CrewMember leonardMcCoy = new CrewMember( "Leonard McCoy", "Chief Medical Officer" );
CrewMember montgomeryScott = new CrewMember( "Montgomery Scott", "Chief Engineering Officer" );
CrewMember jeanLucPicard = new CrewMember( "Jean-Luc Picard", "Commanding Officer" );
CrewMember williamRiker = new CrewMember( "William T. Riker", "First Officer" );
CrewMember beverlyCrusher = new CrewMember( "Beverly Crusher", "Chief Medical Officer" );
CrewMember geordiLaForge = new CrewMember( "Geordi La Forge", "Chief Engineering Officer" );

enterpriseA.addCrewMember( jamesKirk );
enterpriseA.addCrewMember( spock );
enterpriseA.addCrewMember( leonardMcCoy );
enterpriseA.addCrewMember( montgomeryScott );
enterpriseD.addCrewMember( jeanLucPicard );
enterpriseD.addCrewMember( williamRiker );
enterpriseD.addCrewMember( beverlyCrusher );
enterpriseD.addCrewMember( geordiLaForge );

federation.addStarship( enterpriseA );
federation.addStarship( enterpriseD );

System.out.println( federation );

Now that Fleet.java has a main method, it will be the class to run our application.
Note that this code will not compile until you have coded its dependencies. Follow the remaining instructions for each class in this lab in order to get your code to compile - do not change the given main method.


This class will run our application. It will also represent a Fleet object, which we will define as having: This class must have a constructor and getters and setters to accommodate its variables.


This class will represent a Starship object, which we will define as having: For the sake of this lab, a starship will have a maximum of 10 crew members.
This class must have a constructor and getters and setters to accommodate its variables.


This class will represent a CrewMember object, which we will define as having: This class must have a constructor and getters and setters to accommodate its variables.

As this lab is meant to review regular arrays in Java, no other data structure may be used to store the objects required. (No ArrayLists are permitted, for example).


Once your code compiles, you will be able to examine the output of your program. The output of your program must match the format of the sample below. This sample is the result of running the Fleet.java class with the given main method.

United Federation of Planets

USS Enterprise (NCC-1701-A)

[Class: Constitution]
- Commanding Officer: James T. Kirk
- First Officer: Spock
- Chief Medical Officer: Leonard McCoy
- Chief Engineering Officer: Montgomery Scott

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
USS Enterprise (NCC-1701-D)

[Class: Galaxy]
- Commanding Officer: Jean-Luc Picard
- First Officer: William T. Riker
- Chief Medical Officer: Beverly Crusher
- Chief Engineering Officer: Geordi La Forge


Submissions which do not compile will receive a maximum of 10 points total.