diff --git a/Summer-2024/CS-3443/Labs/Lab2/Layout.puml b/Summer-2024/CS-3443/Labs/Lab2/Layout.puml
new file mode 100644
index 0000000..31ae33e
--- /dev/null
+++ b/Summer-2024/CS-3443/Labs/Lab2/Layout.puml
@@ -0,0 +1,67 @@
+@startuml
+skinparam classAttributeIconSize 0
+class CrewMember {
+ - name: String
+ - position: String
+ - rank: String
+ - species: String
+ - assignment: String
+ + <
+ Some notes on the decisions made here.
+
+ Made with infinite, undying, hatred in PlantUML (Lab2,
+ zfp106)
+
+
+
+
+
+ Question
+ Answer
+
+
+ Why is
+ Starship
associated to CrewMember
via
+ aggregation?Because a
+ Starship
has 0 or more crew members and crew
+ members aren't dependent on a Starship
to exist. It is possible for a
+ crew member to not be assigned to any
+ Starship
.
+
+
+
+ Why is
+ Fleet
associated to Starship
via aggregation?
+
+ Same reason as the previous. It is possible for a fleet to exist in name
+ only without any Starships contained within at all. A fleet is quite
+ literally an aggregation of any n number of ships in the first
+ place anyhow.
+
+
+
+ Why does
+ Lab2
with its main
method have a dependency
+ relationship with Fleet
?Because a near identical example of this relationship was in the slides.
+ We will
+ primarily use it for classes referenced in
main
.
+
+
+ Why don't you show associations/other connections to Java standard library classes like
+
+ ArrayList
?
+ Because we can keep going down that rabbit hole until infinity (or by my count in my IDE ~5 - 6 levels of
+ indirection from any given Java standard lib class to the bottom of the chain). I'm not interested in showing
+ the full diagram all the way down until we hit the base
+ Object
class.
Your answers are wrong and you should feel bad.
Them's fighting words, and I have a
+ whole hill here to defend and die upon, sword gleaming in the midnight sun.
The actual UML diagram below:
+ + + + diff --git a/Summer-2024/CS-3443/Labs/Lab2/assets/run-recording.webm b/Summer-2024/CS-3443/Labs/Lab2/assets/run-recording.webm index 2fcd6d9..4bf3ab2 100644 Binary files a/Summer-2024/CS-3443/Labs/Lab2/assets/run-recording.webm and b/Summer-2024/CS-3443/Labs/Lab2/assets/run-recording.webm differ diff --git a/Summer-2024/CS-3443/Labs/Lab2/pom.xml b/Summer-2024/CS-3443/Labs/Lab2/pom.xml index 641738a..03d49dc 100644 --- a/Summer-2024/CS-3443/Labs/Lab2/pom.xml +++ b/Summer-2024/CS-3443/Labs/Lab2/pom.xml @@ -1,10 +1,10 @@A crew member has a name, a position, a rank, a species, and an assignment. + * + *
A crew member may not have an active assignment, meaning they're not assigned to a ship + */ public class CrewMember { private String name; private String position; @@ -7,6 +14,15 @@ public class CrewMember { private String species; private String assignment; + /** + * Create a new crew member with an active assignment to a starship + * + * @param name The name of the crew member + * @param position The position of the crew member + * @param rank The rank of the crew member + * @param species The species of the crew member + * @param assignment The ship registry the crew member is assigned to + */ public CrewMember(String name, String position, String rank, String species, String assignment) { this.setName(name); this.setPosition(position); @@ -15,6 +31,14 @@ public class CrewMember { this.setAssignment(assignment); } + /** + * Create a new crew member with an active assignment to a starship + * + * @param name The name of the crew member + * @param position The position of the crew member + * @param rank The rank of the crew member + * @param species The species of the crew member + */ public CrewMember(String name, String position, String rank, String species) { this.setName(name); this.setPosition(position); @@ -22,47 +46,102 @@ public class CrewMember { this.setSpecies(species); } + /** + * Get the string representation for the crew member + * + * @return String representation of the crew member + */ public String toString() { return String.format( "%s (%s) - %s [%s]", this.getName(), this.getRank(), this.getPosition(), this.getSpecies()); } + /** + * Get the name of the crew member + * + * @return The name of the crew member + */ public String getName() { - return name; + return this.name; } + /** + * Set the name of the crew member + * + * @param name The new name for the crew member + */ public void setName(String name) { this.name = name; } + /** + * Get the position of the crew member + * + * @return The position of the crew member + */ public String getPosition() { - return position; + return this.position; } + /** + * Set the position of the crew member + * + * @param position The new position for the crew member + */ public void setPosition(String position) { this.position = position; } + /** + * Get the rank of the crew member + * + * @return The rank of the crew member + */ public String getRank() { - return rank; + return this.rank; } + /** + * Set the rank of the crew member + * + * @param rank The new rank for the crew member + */ public void setRank(String rank) { this.rank = rank; } + /** + * Get the species of the crew member + * + * @return The species of the crew member + */ public String getSpecies() { - return species; + return this.species; } + /** + * Set the species of the crew member + * + * @param species The new species for the crew member + */ public void setSpecies(String species) { this.species = species; } + /** + * Get the starship registry that the crew member is assigned to + * + * @return The starship registry that the crew member is assigned to + */ public String getAssignment() { - return assignment; + return this.assignment; } + /** + * Set the starship registry that the crew member is assigned to + * + * @param assignment The new starship registry to assign the crew member to + */ public void setAssignment(String assignment) { this.assignment = assignment; } diff --git a/Summer-2024/CS-3443/Labs/Lab2/src/main/java/com/zfp106/lab2/Fleet.java b/Summer-2024/CS-3443/Labs/Lab2/src/main/java/com/zfp106/lab2/Fleet.java index 0b24c78..e38be61 100644 --- a/Summer-2024/CS-3443/Labs/Lab2/src/main/java/com/zfp106/lab2/Fleet.java +++ b/Summer-2024/CS-3443/Labs/Lab2/src/main/java/com/zfp106/lab2/Fleet.java @@ -2,13 +2,17 @@ package com.zfp106.lab2; import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Represents a fleet of starships * - *
Each fleet has the following: - A name - Starships said fleet contains + *
Each fleet has a name and 0 or more starships
*/
public class Fleet {
private String name;
@@ -19,22 +23,11 @@ public class Fleet {
this.setStarships(new ArrayList Each starship has a name, a registry code, a class, and 0 or more crew members
+ */
public class Starship {
private String name;
private String registry;
private String starshipClass;
private ArrayList Note that this will reassign the crew member to the starship
+ *
+ * @param crewMember The crew member to assign to the starship
+ */
public void addCrewMember(CrewMember crewMember) {
if (!this.crew.contains(crewMember)) {
+ crewMember.setAssignment(this.getRegistry());
this.crew.add(crewMember);
}
}
+ /**
+ * Get the number of crew assigned to the starship
+ *
+ * @return The number of crew assigned to the starship
+ */
public Integer getNumberOfPersonnel() {
- return this.crew.size();
+ return this.getCrew().size();
}
+ /**
+ * Get the name of the starship
+ *
+ * @return The name of the starship
+ */
public String getName() {
- return name;
+ return this.name;
}
+ /**
+ * Set the name of the starship
+ *
+ * @param name New name for the starship
+ */
public void setName(String name) {
this.name = name;
}
+ /**
+ * Get the registry code of the starship
+ *
+ * @return The registry code of the starship
+ */
public String getRegistry() {
- return registry;
+ return this.registry;
}
+ /**
+ * Set the registry code of the starship
+ *
+ * @param registry The new registry code for the starship
+ */
public void setRegistry(String registry) {
this.registry = registry;
}
+ /**
+ * Get all of the crew assigned to the starship
+ *
+ * @return The crew assigned to the starship
+ */
public ArrayList