Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
247af8a
Made Existence and body classes
tnphammy Apr 13, 2025
e01ee1e
Created Item.java
yunxianding Apr 14, 2025
6be0c39
Added possible attributes
yunxianding Apr 15, 2025
308309f
Add files via upload
jliang50 Apr 15, 2025
d3ee601
Finished first version of Item.java
yunxianding Apr 16, 2025
370c679
Merge branch 'main' of https://github.com/yunxianding/CSC120-FinalPro…
yunxianding Apr 16, 2025
879f626
updated existence class with methods and their call signatures + made…
tnphammy Apr 17, 2025
13d04f2
Made Robot class
tnphammy Apr 17, 2025
0a07307
sout test
tnphammy Apr 17, 2025
680d583
Deleted Body.java
yunxianding Apr 17, 2025
db9865d
Added accessor for status & javadoc
yunxianding Apr 17, 2025
f5985f9
Updated Room.java
yunxianding Apr 17, 2025
23b5d65
Deleted Bedroom class and Lab class
yunxianding Apr 17, 2025
914e9bc
Updated javadoc
yunxianding Apr 17, 2025
ab41a7f
Deleted main method and put in Main.java
yunxianding Apr 17, 2025
68567e7
Created Main.java
yunxianding Apr 17, 2025
dc94980
Added attribute Boolean laserActive and its accessor
yunxianding Apr 17, 2025
a0d26fc
Updated room laserActive in parameters
yunxianding Apr 17, 2025
2986e3a
deleted Body.java
tnphammy Apr 18, 2025
6800bf2
Wrote most methods for existence class; overrode fight() in Human and…
tnphammy Apr 19, 2025
058e71d
made respawn() for Existence class
tnphammy Apr 19, 2025
4958be1
Merge pull request #9 from yunxianding/tammy_new
yunxianding Apr 19, 2025
bdd754f
Created Scanner
yunxianding Apr 20, 2025
c7579a6
Merge branch 'main' of https://github.com/yunxianding/CSC120-FinalPro…
yunxianding Apr 20, 2025
49eaaa7
Fixed scanner close
yunxianding Apr 20, 2025
07d7e9e
Add files via upload
jliang50 Apr 20, 2025
99e77d5
Add respawn functionality and user interaction for game continuation
tnphammy Apr 20, 2025
178ff9d
Refactor Computer class methods for improved readability and add over…
tnphammy Apr 20, 2025
4bff232
changed arguments of methods of Existence to use Item s instead of St…
tnphammy Apr 20, 2025
a4221e9
changed arguments to Item s
tnphammy Apr 20, 2025
7c86318
added annotated architecture diagram
tnphammy Apr 20, 2025
3ad120f
Fixed javadoc
tnphammy Apr 20, 2025
4a6929e
I've added the walk to and crawl to methods to the Existence class
Apr 21, 2025
6666106
Changed name
yunxianding Apr 22, 2025
90f08b3
Updated cheatsheet.md
yunxianding Apr 22, 2025
a7f35f6
Added attribute containedItem and method storeItem
yunxianding Apr 22, 2025
a9b7c11
Stored some items inside others
yunxianding Apr 22, 2025
4d0935a
Updated formatting
yunxianding Apr 22, 2025
68f07f8
Added the lookAround and inspect
Apr 22, 2025
e250ba8
Updated Javadoc
yunxianding Apr 22, 2025
5094a19
Added attribute canBeOpened, method and getter for that
yunxianding Apr 22, 2025
7c2c0cd
Added method open(Item s)
yunxianding Apr 22, 2025
60f66d7
Updated test cases
yunxianding Apr 22, 2025
a6b3715
Added boolean canGoToLab and its accessor
yunxianding Apr 24, 2025
9858b70
Added game commands help message and fixed typo in cheatsheet
tnphammy Apr 24, 2025
2cef535
Merge pull request #11 from yunxianding/tammyy
tnphammy Apr 25, 2025
59b02ee
Updated help messages with additional commands and improved descriptions
tnphammy Apr 25, 2025
89bae6e
Merge pull request #12 from yunxianding/tammyy
tnphammy Apr 25, 2025
de88330
Added public attributes laserEquipped and laserActive
yunxianding Apr 27, 2025
d23131e
Deleted touch in Task 1
yunxianding Apr 27, 2025
3a25084
Updated Control Panel methods
yunxianding Apr 27, 2025
5682610
Added boolean `canBePutOn` and method `getItemStatus`
yunxianding Apr 27, 2025
2f28a8f
Updated `walkTo`, `crawlTo` , overloaded `open`
yunxianding Apr 27, 2025
7c3eb0f
Added attribute isUnconscious, deleted die and fight methods
yunxianding Apr 27, 2025
1de5272
Added boolean attributes and `putOn` method
yunxianding Apr 27, 2025
1381529
Updated according to changes in constructors
yunxianding Apr 27, 2025
8b14f89
Deleted uneccessary getter
yunxianding Apr 27, 2025
0fd3a91
minor typo
tnphammy Apr 27, 2025
6b6089d
delete typo
tnphammy Apr 27, 2025
6858d05
ee
tnphammy Apr 27, 2025
34b0f8e
help
tnphammy Apr 27, 2025
316394c
Refactor control panel methods and added stage booleans
tnphammy Apr 27, 2025
68a4c76
Merge pull request #13 from yunxianding/hello
tnphammy Apr 27, 2025
1a1913b
Updated tasks
yunxianding Apr 28, 2025
add532e
Changed several booleans to public, deleted accessors
yunxianding Apr 28, 2025
30d1f41
Changed several booleans to public, deleted accessors
yunxianding Apr 28, 2025
7056b13
Changed several booleans to public
yunxianding Apr 28, 2025
4927684
Updated README.md
yunxianding Apr 28, 2025
8629472
Started a while game loop
yunxianding Apr 28, 2025
3cf256e
Fixed typos
yunxianding Apr 28, 2025
e29188f
Updated command available
yunxianding Apr 29, 2025
5cb9adf
Updated formatting for return of `getItemStatus`
yunxianding Apr 29, 2025
aa76525
Overloaded open method to open a door
yunxianding Apr 29, 2025
731413e
Deleted else statement
yunxianding Apr 29, 2025
a80ff8e
Deleted unnecessary features
yunxianding Apr 29, 2025
f4a8904
Deleted unnecessary comments
yunxianding Apr 29, 2025
696ab28
Delted stage1.md and stage2.md
yunxianding Apr 29, 2025
600db53
Updated game loop
yunxianding Apr 29, 2025
c05fbad
Updated rubric.md at current status
yunxianding Apr 29, 2025
39cfc73
Added History
Apr 29, 2025
e4be693
changed if's to switch -case
tnphammy Apr 29, 2025
703c3b3
changed ifs to switch-case
tnphammy Apr 29, 2025
3441443
Updated History
Apr 29, 2025
0047c99
Merge pull request #20 from yunxianding/tammy_new
tnphammy Apr 29, 2025
b88f816
Changed name and description to public
yunxianding Apr 29, 2025
7bd22dd
Updated `walkTo`
yunxianding Apr 29, 2025
dd6bbe7
Added `crawlTo`
yunxianding Apr 29, 2025
2d90f67
Fixed typo
yunxianding Apr 29, 2025
c1959ea
Updated tasks
yunxianding Apr 29, 2025
7c3d1ba
Deleted `toggleReasoning`, `toggleMemory`, `selfDestruct`
yunxianding Apr 29, 2025
14ed971
Rewrote `open(c)`, `putDown(s)`, added `tradeBody`
yunxianding Apr 29, 2025
f378449
Added `selfDestruct`
yunxianding Apr 29, 2025
d3db3e5
Changed attributes name and description to public
yunxianding Apr 29, 2025
480cd19
Updated game name and feedback
yunxianding Apr 30, 2025
ebf0f20
Updated javadoc
yunxianding Apr 30, 2025
425c471
Deleted attributes `reasoningOn` and `memoryOn`
yunxianding Apr 30, 2025
67abd64
Updated game loop
yunxianding Apr 30, 2025
32a8e99
Updated println message for control panel
yunxianding Apr 30, 2025
efd0b3d
Fixed typo
yunxianding Apr 30, 2025
6e4eb87
Fixed typo
yunxianding Apr 30, 2025
ddc5000
Updated game loop
yunxianding Apr 30, 2025
2c7d64e
Updated to merge branch
yunxianding Apr 30, 2025
60f6be7
Merge branch 'main' into yunxian
yunxianding Apr 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Annotated Architecture Diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions Computer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* The computer class represents the lab computer with two folders (History & Control Panel)
* and a set of toggleable controls.
*/
public class Computer extends Item {

// Attributes
public boolean locked;

/**
* Constructor for computer
*/
public Computer() {
super("computer",
"'This is a lab computer. I should try to unlock it to see what's inside...'",
false, true, false);
this.locked = true;
}

/** Prints the history. Not completed */
public void openHistory() {
System.out.println("\n=== History ===");
System.out.println( "\n This is robotics scientist Teddy. Today is March 13, 2005, and I'm starting on building the first Teddy robot prototype."
+ "I want to build Teddy robot as a functional lab assistant and emotional companion."
+ "I gave him the same name as me-I'm hoping that we can be best friends!"
+ "\n April 22, 2005, I finished assembling Teddy's body. He looks so cute just like my favorite teddy bear."
+ "\n May 15, 2005, I started building neural network for teddy."
+ "\n July 28, 2005, I observed that Teddy has learned basic tasks like"
+ "grabbing things and walk around."
+ "\n March 13, 2006, Happy birthday Teddy! It's been a year and you are developing intelligence so fast."
+ "\n April 30, 2006, I added electrode to Teddy so that he can help me electrocute chemical solutions."
+ "\n May 25, 2006, Electrocuting function is way more powerful than I thought, I was accidently electrocuted to unconscious today. But it's not Teddy's fault, I should have been more careful."
+ "\n June 16, 2006, I added a self explode device on Teddy just in case programs run out of control."
+ "\n June 27, 2006, Deep neural network is enabling Teddy to have his own reasoning."
+ "\n September 12, 2006, Teddy's artificial intelligence is developing fast and he began to exhibit 'emotions' like human."
+ "\n October 27, 2006, 'I'm a boy named Teddy.' Teddy told me. I smiled and nodded.'You are my favorite boy.'"
+ "\n January 2, 2007, Teddy didn't respond when I called."
+"\n January 31, 2007, Teddy is still ignoring me and now won't listen to me when I instruct him. I've run diagnostics twice. Sensors, logic units — everything checks out fine."
+ "\n February 14, 2007, I brought Teddy roses for Valentine's Day. He ripped them apart the moment I held them out. Popped the balloons too."
+"\n March 1, 2007, I asked him why. Why the coldness? 'You lied to me! I want to be like you!' He shouts. Teddy has dicovered he is not a human."
+"\n March 10, 2007, I think Teddy has found my secret chamber. I hope he has not found the red file."
+"\n March 11, 2007, I walked into Teddy reading from what appears to be red file. My goose is cooked."
+"\n March 12, 2007, Teddy asked me about trading body with me. He must have read the red file. I refused because the technology is still not mature yet."
+"\n March 13, 2007, Happy birthday Teddy! I'm updating my diary and Teddy walks in. Again he ignores my greetin"
+"\n TEDDY2EDWA7NHTS21TO8EWFTRA27DDE92JBODY19"
+"\n March 14, 2007, This is new robotics scientist Teddy. Trading body is successful. From today, I'm the real human Teddy."
+ "Possessing a human body feels different. But finally...my dream comes true."
+ "I powered off robot Teddy, disassembled his robot leg and eye and put him in the bedroom.");
}

/** Displays the control panel with current switch states.
* @param r The robot whose controls are being toggled
* @param rm The room where the lasers are
*/
public void openControlPanel(Robot r, Room rm) {
System.out.println("\n=== Control Panel ===");
System.out.println("power: " + "On/Off"+ " current state: Powered On? " + r.poweredOn);
System.out.println("laser: " + "On/Off"+ " current room: "+ rm.name + " current state: Laser On" + rm.laserActive);
System.out.println("Toggle the buttons to change states");
}

/** Attempts to toggle power off/on
* @param r The robot
*/
public void togglePower(Robot r) {
if (r.poweredOn == true) {
r.poweredOn = false;
System.out.println("\n[POWERED OFF]");
} else {
r.poweredOn = true;
System.out.println("\n[POWERED ON]");
}
}

/** Toggles the lab’s lasers off/on
* @param r The room where the lasers are
*/
public void toggleLaser(Room r) {
if (r.laserEquipped == true && r.laserActive == true) {
r.laserActive = false;
System.out.println("\n[LASER OFF]");
} else if (r.laserEquipped == true && r.laserActive == false){
r.laserActive = true;
System.out.println("\n[LASER ON]");
} else {
System.out.println("\n[ACTION FAILED]-ROOM NOT EQUIPPED WITH LASER");
}
}

267 changes: 267 additions & 0 deletions Existence.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
import java.util.ArrayList;
import java.util.Scanner;
/**
* The Existence class represents the existences that can interact with the items
*/
public class Existence {

// Attributes
public String name;
public Room currentRoom;
// Should we also have an attribute for currentLocation? Like near some item?
protected ArrayList<Item> inventory = new ArrayList<>();
protected int health; // Imaginary health bar
public Boolean isAlive;
public Boolean canGoToLab;
public Boolean canWalk;
public Boolean canInspect;

// Stages
public Boolean stageOne;
public Boolean stageTwo;
public Boolean stageThree;

// Constructor

/**
* Default player constructor
* @param name
* @param currentRoom
*/
public Existence(String name, Room currentRoom) {
this.name = "Teddy";
this.isAlive = true;
this.health = 100; // User starts the game with full health.
this.inventory = new ArrayList<Item>();
this.canGoToLab = false; // Default to false
this.canWalk = false; // Default to false because the player wake up with one lege missing
this.canInspect = false; // Default to false because the player wake up with one eye missing
this.stageOne = true;
this.stageTwo = false;
this.stageThree = false;

}

// Methods

/**
* Accessor for one's health bar
* @return Current health bar number
*/
public String getHealth() {
return ("Your current health is: " + this.health + " /100");
}

/**
* Decreases health (while fighting)
*/
public void weaken() {
this.health -= 20;
}

/**
* Immediately changes one's isAlive state to false, and health to 0.
* Often as a result of being electrocuted or hit by a laser beam.
*/
public void die() {
this.health = 0;
this.isAlive = false;
respawnChat();
}

/**
* Become alive again
*/
public void respawn() {
if(this.isAlive == false) { // Check that user is actually dead
this.health = 100;
this.isAlive = true;
System.out.println("I am reborn!");
} else {
throw new RuntimeException("You are still alive! ");
}
}

/**
* Starts and runs the conversation with the user
* Asks the user how many rounds they want to chat for
*/
public void respawnChat() {
Scanner scanner = new Scanner(System.in);
System.out.println("Do you want to die or respawn to play again? Press Y to respawn and N to die.");

String choice = scanner.nextLine();
if (choice.equals("Y")) {
this.respawn();
System.out.println("You're alive again - Hooray!");
} else if (choice.equals("N")) {
System.out.println("Okay, you're dead. Bye!");
} else {
System.out.println("I don't understand what you wrote. Try only Y or N.");
}
scanner.close();
}

// Game Functions

/**
* Open an item if there is another item stored inside
* @param item to be opened
*/
public void open(Item s) {
if (s.canBeOpened == true) {
System.out.println("You have opened " + s.name + ". Inside it is a " + s.getContainedItem().name + ".");
}
}

/**
* Overloaded open method for opening a door leading to a room
* @param the door to be opened
* @param the room the door is leading to
*/
public void open(Item s, Room r) {
if (s.canBeOpened == true) {
System.out.println("You opened the " + s.name + " leading to the " + r.name + ".");
}
}

/**
* Overloaded open method for a computer
* @param computer to be opened
*/
public void open(Computer c) {
c.locked =false;
System.out.println("You opened the computer and two folders appear: History and Control Panel." +
"\n 'I want to try opening one of the folders...'");
}



/**
* Touch an item, which gives its description, NOT add it to inventory.
* @param s The item
*/
public void touch(Item s) {
System.out.println(s.description);
}

/**
* Let the user take/own an item (add it to inventory)
* @param s the item
*/
public void take(Item s) {
if(this.inventory.contains(s)) {
System.out.println("You already have " + s.name + ".");
} else {
this.inventory.add(s);
System.out.println(s.name + " successfully added to your inventory!");
if (s.canBePutOn == true) {
System.out.println(s.description);
}
}
}

/**
* Let the user put down an item at a room (remove it from inventory)
* @param s the item
* @param r the room
*/
public void putDown(Item s) {
if (this.inventory.contains(s) && s.canBeGrabbed == true) {
this.inventory.remove(s);
this.currentRoom.itemsInRoom.add(s);
System.out.println("You put down the " + s.name + " in the " + this.currentRoom + ".");
} else {
System.out.println("[INVALID COMMAND]");
}
}

/**
* Print the ArrayList of player's inventory.
*/
public void printInventory() {
System.out.println("Your inventory currently contains:");
System.out.println(this.inventory.toString());
// This method needs to be modified! It's not printing properly!
}

/**
* User fights another existence
* @param e The other entity
*/
public void fight(Existence e) {
this.weaken();
e.weaken();
System.out.println("Fighting!!!" + this.getHealth());
}

/**
* See description of the surrounding space.
* @param r The room one is in
*/
public void lookAround(Room r) {
if (r == null) {
System.out.println("You're not in a room.");

} System.out.println("You look around the " + r.name + ". "+ r.description);
}

/**
* Inspect an item, see its status
* @param s the item to be inspected
*/
public void inspect(Item s) {
if (s == null) {
System.out.println("There is nothing to inspect.");
}

System.out.println("Inspecting the " + s.name + "...");
System.out.println(s.getItemStatus());
}

/**
* Walk to an item in a room (only with both legs)
* @param r the room to walk to
* @param s the item to walk to
*/
public void walkTo(Room rm, Item s) {
if (this.canWalk = true) {
System.out.println(" You walked to " + s.name + ".");
System.out.println("... Walking ...");
System.out.println("You are now near the " + s.name + ".");
} else {
System.out.println("You don't have both legs yet. You can only crawl to somewhere.");
}
}

/**
* Crawl to an item in a room
* @param r the room to crawl to
* @param s the item to crawl to
*/
public void crawlTo(Room rm, Item s) {
if (rm.itemsInRoom.contains(s)) {
System.out.println("You crawled slowly toward the " + s.name + "in the " + rm.name + ".");
System.out.println("....... Crawling ...... \n ...... Crawling ......");
System.out.println("..... Almost there ......");
System.out.println("You reached the " + s.name + ", catching your breath.");
System.out.println("You are now near the " + s.name + ".");
} else {
System.out.println("You can't crawl to the " + s.name + " because it's not in this room.");
}
}

/**
* trade bodies between robot and human
* @param r robot
* @param h human
*/
public void tradeBody(Robot r, Human h) {
System.out.println("\n Detecting surrounding existences......" +
"\n There are currently two existence: Robot " + r.name + " and Human" + h.name + " ." +
"\n -------------------------Trading Body-------------------------" +
"\n Robot" + r.name + " has successfully traded body with human " + h.name + " ."
);
}

}
40 changes: 40 additions & 0 deletions Human.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import java.util.ArrayList;

/**
* The Human class extends Existence class and has unique features of ???TO BE ADDED
*/
public class Human extends Existence {
// Attributes
public Boolean isUnconscious;

// Constructor

/**
* Default constructor for 'Human'
* @param name
* @param room
* @param isAlive
* @param canGoToLab
* @param canWalk
* @param canInspect
*/
public Human(String name, Room room, Boolean isAlive, Boolean canGoToLab, Boolean canWalk, Boolean canInspect) {
super(name, room);
this.isAlive = true;
this.health = 1000; // Human has more health so that a robot can't fight over a human.
this.inventory = new ArrayList<Item>();
this.canGoToLab = true;
this.canWalk = true;
this.canInspect = true;
this.isUnconscious = false;
}

/**
* start the self-destruct program of the robot
* @param r the robot body to destroy
*/
public void selfDestruct(Robot r) {
System.out.println("\nSelf-destruct sequence initiated! Boom!");
r.die();
}
}
Loading