cs-3443: init lab2
This commit is contained in:
parent
cc2fbeb808
commit
8fd941d5cf
5
Summer-2024/CS-3443/Labs/Lab2/.gitignore
vendored
Normal file
5
Summer-2024/CS-3443/Labs/Lab2/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
.classpath
|
||||
.settings/
|
||||
target/
|
||||
.metadata/
|
||||
.project
|
157
Summer-2024/CS-3443/Labs/Lab2/Assignment.org
Normal file
157
Summer-2024/CS-3443/Labs/Lab2/Assignment.org
Normal file
@ -0,0 +1,157 @@
|
||||
*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*.
|
||||
|
||||
#+begin_src
|
||||
----------------------------
|
||||
|
||||
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.
|
||||
#+end_src
|
||||
|
||||
** 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)
|
28
Summer-2024/CS-3443/Labs/Lab2/README.org
Normal file
28
Summer-2024/CS-3443/Labs/Lab2/README.org
Normal file
@ -0,0 +1,28 @@
|
||||
* Lab 1 Submission
|
||||
Name: =Price Hiller=
|
||||
ABC123: =zfp106=
|
||||
Date: =2024-06-12=
|
||||
URL: [[https://git.orion-technologies.io/Price/college/src/branch/Development/Summer-2024/CS-3443/Labs/Lab1]]
|
||||
|
||||
** Running the program
|
||||
|
||||
Recording of the program running: [[file:./assets/run-recording.webm]]
|
||||
|
||||
*** via Eclipse
|
||||
|
||||
- Open Eclipse
|
||||
- Select File
|
||||
- Select Import
|
||||
- In the dialogue that appears, expand =General=
|
||||
- Select =Archive File=
|
||||
- Click =Next=
|
||||
- In the top right of the new menu, select =Browse...=
|
||||
- Find the archive on your file system and select it
|
||||
- Select a valid path for =Into folder:=
|
||||
- Click =Finish=
|
||||
- Select the project on the left bar
|
||||
- On the top bar, expand the =Run= category
|
||||
- Click =Run=
|
||||
|
||||
*** via Maven
|
||||
If you have Maven installed, you can easily run this program when at the top level of the project via ~mvn exec:java -Dexec.mainClass="com.zfp106.lab1.Lab1"~.
|
BIN
Summer-2024/CS-3443/Labs/Lab2/assets/run-recording.webm
Normal file
BIN
Summer-2024/CS-3443/Labs/Lab2/assets/run-recording.webm
Normal file
Binary file not shown.
9
Summer-2024/CS-3443/Labs/Lab2/data/NCC-1701-A.csv
Normal file
9
Summer-2024/CS-3443/Labs/Lab2/data/NCC-1701-A.csv
Normal file
@ -0,0 +1,9 @@
|
||||
USS Enterprise,NCC-1701-A,Constitution
|
||||
James T. Kirk,Commanding Officer,Captain,Human
|
||||
Spock,First Officer,Commander,Vulcan/Human
|
||||
Leonard McCoy,Chief Medical Officer,Lieutenant Commander,Human
|
||||
Montgomery Scott,Chief Engineering Officer,Lieutenant Commander,Human
|
||||
Christine Chapel,Nurse,Crewman,Human
|
||||
Nyota Uhura,Communications Officer,Lieutenant,Human
|
||||
Hikaru Sulu,Helmsman,Lieutenant,Human
|
||||
Pavel Chekov,Navigator,Ensign,Human
|
|
9
Summer-2024/CS-3443/Labs/Lab2/data/NCC-1701-D.csv
Normal file
9
Summer-2024/CS-3443/Labs/Lab2/data/NCC-1701-D.csv
Normal file
@ -0,0 +1,9 @@
|
||||
USS Enterprise,NCC-1701-D,Galaxy
|
||||
Jean-Luc Picard,Commanding Officer,Captain,Human
|
||||
William T. Riker,First Officer,Commander,Human
|
||||
Beverly Crusher,Chief Medical Officer,Lieutenant Commander,Human
|
||||
Geordi La Forge,Chief Engineering Officer,Lieutenant,Human
|
||||
Deanna Troi,Counselor,Lieutenant Commander,Betazoid
|
||||
Worf,Helmsman,Lieutenant,Klingon
|
||||
Data,Chief Operations Officer,Lieutenant Commander,Android
|
||||
Tasha Yar,Chief Security Officer,Lieutenant,Human
|
|
1
Summer-2024/CS-3443/Labs/Lab2/data/NCC-1941-A.csv
Normal file
1
Summer-2024/CS-3443/Labs/Lab2/data/NCC-1941-A.csv
Normal file
@ -0,0 +1 @@
|
||||
USS Bozeman,NCC-1941-A,Sovereign
|
|
1
Summer-2024/CS-3443/Labs/Lab2/data/NCC-1941.csv
Normal file
1
Summer-2024/CS-3443/Labs/Lab2/data/NCC-1941.csv
Normal file
@ -0,0 +1 @@
|
||||
USS Bozeman,NCC-1941,Soyuz
|
|
1
Summer-2024/CS-3443/Labs/Lab2/data/NCC-71805.csv
Normal file
1
Summer-2024/CS-3443/Labs/Lab2/data/NCC-71805.csv
Normal file
@ -0,0 +1 @@
|
||||
USS Endeavour,NCC-71805,Nebula
|
|
1
Summer-2024/CS-3443/Labs/Lab2/data/NCC-75689.csv
Normal file
1
Summer-2024/CS-3443/Labs/Lab2/data/NCC-75689.csv
Normal file
@ -0,0 +1 @@
|
||||
USS Gibraltar,NCC-75689,Sovereign
|
|
47
Summer-2024/CS-3443/Labs/Lab2/pom.xml
Normal file
47
Summer-2024/CS-3443/Labs/Lab2/pom.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.zfp106.lab1</groupId>
|
||||
<artifactId>lab1</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.1</version>
|
||||
<name>lab1</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit</groupId>
|
||||
<artifactId>junit-bom</artifactId>
|
||||
<version>5.10.2</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.2.5</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>com.zfp106.lab1.Lab1</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Lab2 is a Java class containing a main method to run your program when completed.
|
||||
* This class will not compile until you have completed the requirements outlined in
|
||||
* the lab description.
|
||||
*
|
||||
* @author Amanda Fernandez (abc123)
|
||||
* UTSA CS 3443 - Lab 2
|
||||
* Fall 2022
|
||||
*/
|
||||
public class Lab2 {
|
||||
|
||||
public static void main( String[] args ) {
|
||||
|
||||
Fleet unitedFederation = new Fleet( "United Federation of Planets" );
|
||||
|
||||
try {
|
||||
unitedFederation.loadStarships( "data" );
|
||||
|
||||
}catch( Exception e ) {
|
||||
// this is a try/catch which will show any errors to the console (more on these in coming weeks!)
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println( unitedFederation );
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user