commit dd34c8d450dc05a901f0ed87c869f2f3f0f16e27
parent 2f135e3e9f265b27612735fbdb7db87fcafa9ae3
Author: thing1 <thing1@seacrossedlovers.xyz>
Date: Thu, 5 Mar 2026 10:38:42 +0000
did test
Diffstat:
11 files changed, 159 insertions(+), 0 deletions(-)
diff --git a/CS12320/test/2/8/Room.class b/CS12320/test/2/8/Room.class
Binary files differ.
diff --git a/CS12320/test/2/8/Room.java b/CS12320/test/2/8/Room.java
@@ -0,0 +1,70 @@
+package Monster;
+
+import java.util.*;
+
+public class Room {
+ private String name;
+ private Room north, south, east, west;
+ private ArrayList<Treasure> treasures;
+
+ public Room(String name) { this.name = name; }
+
+ public Room(String name, Room north, Room south, Room east, Room west) {
+ this.name = name;
+ this.north = north;
+ this.south = south;
+ this.east = east;
+ this.west = west;
+ treasures = new ArrayList<>();
+ }
+
+ public void setNorth(Room north) { this.north = north; }
+ public void setSouth(Room south) { this.south = south; }
+ public void setEast(Room east) { this.east = east; }
+ public void setWest(Room west) { this.west = west; }
+
+ public Room getNorth() { return this.north; }
+ public Room getSouth() { return this.south; }
+ public Room getEast() { return this.east; }
+ public Room getWest() { return this.west; }
+
+ public String getName() { return this.name; }
+
+ //
+ // NEW FEATURE
+ //
+
+ /**
+ * Add a new treasure to the list of treasures in the room
+ * @param t the new treasure to be added
+ */
+ public void addTreasure(Treasure t) {
+ this.treasures.add(t);
+ }
+
+ /**
+ * Get the number of treasures in the room
+ * @return The number of treasures
+ */
+ public int numTreasures() {
+ return this.treasures.size();
+ }
+
+ /**
+ * Print all the treasures in a Room
+ */
+ public void printTreasures() {
+ for (Treasure t : treasures) {
+ System.out.println(t.toString());
+ }
+ }
+
+ /**
+ * Remove a treasure from a room
+ * @param i The index of the treasure to remove
+ * @return The that was removed
+ */
+ public Treasure removeTreasure(int i) {
+ return this.treasures.remove(i);
+ }
+};
diff --git a/CS12320/test/2/8/Treasure.class b/CS12320/test/2/8/Treasure.class
Binary files differ.
diff --git a/CS12320/test/2/8/Treasure.java b/CS12320/test/2/8/Treasure.java
@@ -0,0 +1,47 @@
+package Monster;
+
+
+/**
+ * stores the kind of Treasure
+ */
+enum TreasureType {
+ GEM,
+ COIN,
+ POTION
+}
+
+public class Treasure {
+ private TreasureType treasureType;
+ private String treasureColor;
+ private int specialPowerPoints;
+
+ public Treasure(TreasureType treasureType, String treasureColor, int specialPowerPoints) {
+ this.treasureType = treasureType;
+ this.treasureColor = treasureColor;
+ this.specialPowerPoints = specialPowerPoints;
+ }
+
+ public TreasureType getTreasureType() {
+ return this.treasureType;
+ }
+
+ public void setTreasureColor(String treasureColor) {
+ this.treasureColor = treasureColor;
+ }
+
+ public String getTreasureColor() {
+ return this.treasureColor;
+ }
+
+ public void setPowerPoints(int specialPowerPoints) {
+ this.specialPowerPoints = specialPowerPoints;
+ }
+
+ public int getPowerPoints() {
+ return this.specialPowerPoints;
+ }
+
+ public String toString() {
+ return "A " + this.treasureColor + " " + this.treasureType;
+ }
+};
diff --git a/CS12320/test/2/8/TreasureType.class b/CS12320/test/2/8/TreasureType.class
Binary files differ.
diff --git a/CS12320/test/2/App.class b/CS12320/test/2/App.class
Binary files differ.
diff --git a/CS12320/test/2/App.java b/CS12320/test/2/App.java
@@ -0,0 +1,14 @@
+public class App {
+ public static void main(String[] args) {
+ Foo f;
+ Bar b;
+
+ f = new Foo("Hello");
+ b = new Bar("World");
+
+ f.setBar(b);
+ b.setFoo(f);
+
+ System.out.println(f);
+ }
+}
diff --git a/CS12320/test/2/Bar.class b/CS12320/test/2/Bar.class
Binary files differ.
diff --git a/CS12320/test/2/Bar.java b/CS12320/test/2/Bar.java
@@ -0,0 +1,14 @@
+public class Bar {
+ private Foo foo;
+ private String thing;
+ public Bar(String thing) {
+ this.thing = thing;
+ }
+ public void setFoo(Foo f) {
+ this.foo = f;
+ }
+ public String toString() {
+ return "Bar thing is " + this.thing
+ + " with Foo greeting" + foo.toString();
+ }
+}
diff --git a/CS12320/test/2/Foo.class b/CS12320/test/2/Foo.class
Binary files differ.
diff --git a/CS12320/test/2/Foo.java b/CS12320/test/2/Foo.java
@@ -0,0 +1,14 @@
+public class Foo {
+ private Bar bar;
+ private String greeting;
+ public Foo(String aGreeting) {
+ this.greeting = aGreeting;
+ }
+ public void setBar(Bar b) {
+ this.bar = b;
+ }
+ public String toString() {
+ return "Foo greeting is " + this.greeting
+ + " with Bar thing " + bar.toString();
+ }
+}