Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
b2c1b65
Coordinates.java
ANjiaLuu Apr 18, 2025
7e843c6
Update Coordinates.java
Savannah0215 Apr 18, 2025
8dcdd29
Create NPC.java
Savannah0215 Apr 18, 2025
94209d6
Create Player.java
Savannah0215 Apr 18, 2025
fbd3f83
Create Map.java
Savannah0215 Apr 18, 2025
ce6431c
Create Item.java
Savannah0215 Apr 18, 2025
a4aa7d9
Update Coordinates.java
Savannah0215 Apr 18, 2025
0b151d8
Update Coordinates.java
Savannah0215 Apr 18, 2025
03f8df3
NPC.java
ANjiaLuu Apr 18, 2025
25c5647
Update Item.java
Savannah0215 Apr 18, 2025
e72cbb6
Command.java
ANjiaLuu Apr 19, 2025
0fed4f5
Gameloop.java
ANjiaLuu Apr 19, 2025
4524035
NPC.java
ANjiaLuu Apr 19, 2025
4ffad2e
Command.java
ANjiaLuu Apr 19, 2025
3623de9
Gameloop.java
ANjiaLuu Apr 19, 2025
217d939
NPC.java
ANjiaLuu Apr 19, 2025
120ce3f
Gameloop.java
ANjiaLuu Apr 19, 2025
ec06611
NPC.java
ANjiaLuu Apr 19, 2025
101ce62
Gameloop.java
ANjiaLuu Apr 19, 2025
6d5688e
Gameloop.java
ANjiaLuu Apr 19, 2025
4775e01
Gameloop.java
ANjiaLuu Apr 19, 2025
1947e8f
Gameloop.java
ANjiaLuu Apr 19, 2025
86d697c
Gameloop.java
ANjiaLuu Apr 19, 2025
67a5120
Gameloop.java
ANjiaLuu Apr 19, 2025
21e2996
Gameloop.java
ANjiaLuu Apr 19, 2025
a093732
Create Building.java
Hanyu-Li04 Apr 19, 2025
02cd78d
Gameloop.java
ANjiaLuu Apr 20, 2025
dd1322a
Update Item.java
Savannah0215 Apr 20, 2025
efa6fd0
Update Item.java
Savannah0215 Apr 20, 2025
915381e
Update Building.java
Hanyu-Li04 Apr 20, 2025
cb0191f
Update Coordinates.java
Hanyu-Li04 Apr 20, 2025
0b852e8
Command.java
ANjiaLuu Apr 20, 2025
a195219
Gameloop.java
ANjiaLuu Apr 20, 2025
38e9938
NPC.java
ANjiaLuu Apr 20, 2025
37ef875
NPC.java
ANjiaLuu Apr 20, 2025
019c35b
NPC.java
ANjiaLuu Apr 20, 2025
086f0a3
Gameloop.java
ANjiaLuu Apr 20, 2025
48d6dc3
NPC.java
ANjiaLuu Apr 20, 2025
7100248
Gameloop.java
ANjiaLuu Apr 20, 2025
532208f
Add files via upload
ANjiaLuu Apr 20, 2025
892b7a4
Update Item.java
Savannah0215 Apr 22, 2025
b079368
Gameloop.java
ANjiaLuu Apr 22, 2025
0ed857f
Update Command.java
Savannah0215 Apr 22, 2025
51b4ccf
Update Item.java
Savannah0215 Apr 22, 2025
31ed948
Update Building.java
Savannah0215 Apr 22, 2025
76cc1b8
Gameloop.java
ANjiaLuu Apr 22, 2025
6680cc5
Update Building.java
Savannah0215 Apr 22, 2025
88773a4
Command.java
ANjiaLuu Apr 22, 2025
e2236ee
Gameloop.java
ANjiaLuu Apr 22, 2025
bcebb95
Diagram.pdf
ANjiaLuu Apr 22, 2025
2dba271
Update Command.java
Savannah0215 Apr 22, 2025
6994c4e
Added Player class
Apr 23, 2025
87151b6
Update Command.java
Savannah0215 Apr 24, 2025
27a58ae
Merge pull request #1 from Shakila-Jafari/main
Savannah0215 Apr 24, 2025
92ba941
Update Gameloop.java
Savannah0215 Apr 24, 2025
32270e5
Update Command.java
Savannah0215 Apr 24, 2025
673d0ee
Update NPC and Gameloop classes
Apr 27, 2025
c15e56f
Update Item.java
Savannah0215 Apr 27, 2025
cb84f62
Update Building.java
Savannah0215 Apr 27, 2025
ee3b46e
Update Item.java
Savannah0215 Apr 27, 2025
13aae05
Your message about changes to Gameloop.java
Apr 27, 2025
e5f4d39
Merge remote-tracking branch 'origin/main'
Apr 27, 2025
06537dd
Add files via upload
ANjiaLuu Apr 27, 2025
08ca89d
Update Gameloop.java
Hanyu-Li04 Apr 27, 2025
96bd2b2
Update Gameloop.java
Hanyu-Li04 Apr 27, 2025
c126f33
Update Player.java
Shakila-Jafari Apr 27, 2025
60faa62
Gameloop.java
ANjiaLuu Apr 29, 2025
5461e73
Gameloop.java
ANjiaLuu Apr 29, 2025
45d75a1
Update Gameloop.java
Hanyu-Li04 Apr 29, 2025
58e8bd8
Update Gameloop.java
Hanyu-Li04 Apr 29, 2025
7d0d2f5
Update Gameloop.java
Hanyu-Li04 Apr 29, 2025
60f2a0e
Gameloop.java
ANjiaLuu Apr 30, 2025
306563f
Gameloop.java
ANjiaLuu Apr 30, 2025
df58ba8
Gameloop.java
ANjiaLuu Apr 30, 2025
54ba96d
cheatsheet.md
ANjiaLuu Apr 30, 2025
6bc9759
cheatsheet.md
ANjiaLuu Apr 30, 2025
47cf39f
Gameloop.java
ANjiaLuu Apr 30, 2025
c23d35d
Gameloop.java
ANjiaLuu Apr 30, 2025
2490bd1
Gameloop.java
ANjiaLuu Apr 30, 2025
887f1a1
Update cheatsheet.md
Hanyu-Li04 Apr 30, 2025
33f4476
Update Building.java
Hanyu-Li04 Apr 30, 2025
7cd3b8e
Delete Coordinates.java
Hanyu-Li04 Apr 30, 2025
8f3ac88
Delete Map.java
Hanyu-Li04 Apr 30, 2025
cd0d7d2
Update Item.java
Hanyu-Li04 Apr 30, 2025
7e6b539
Update NPC.java
Hanyu-Li04 Apr 30, 2025
8b4ee2e
Update Player.java
Hanyu-Li04 Apr 30, 2025
a842bd4
Update Gameloop.java
Hanyu-Li04 Apr 30, 2025
3b684b3
Update cheatsheet.md
Hanyu-Li04 May 1, 2025
9fe94d9
Update cheatsheet.md
Hanyu-Li04 May 1, 2025
cc72730
Update cheatsheet.md
Hanyu-Li04 May 1, 2025
8fe7cff
Update cheatsheet.md
Hanyu-Li04 May 1, 2025
09fefec
Update cheatsheet.md
Hanyu-Li04 May 1, 2025
52ca302
Update cheatsheet.md
Hanyu-Li04 May 1, 2025
0455d11
Update Gameloop.java
Hanyu-Li04 May 1, 2025
afd4b38
Add files via upload
Hanyu-Li04 May 1, 2025
599b7f7
Update rubric.md
Hanyu-Li04 May 1, 2025
7b11591
Update Gameloop.java
Hanyu-Li04 May 1, 2025
cbb4bf8
Update cheatsheet.md
Hanyu-Li04 May 1, 2025
633f18f
Update Player.java
Hanyu-Li04 May 1, 2025
ed3e734
Update cheatsheet.md
Hanyu-Li04 May 1, 2025
c990a03
Delete Diagram.png
Hanyu-Li04 May 6, 2025
b70034e
Add files via upload
Hanyu-Li04 May 6, 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
13 changes: 13 additions & 0 deletions Building.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Building {

public String name;
public String description;
public Coordinates location;

public Building(String name, String description, Coordinates location) {
this.name = name;
this.description = description;
this.location = location;
}

}
91 changes: 91 additions & 0 deletions Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// import java.util.Scanner;
// import javax.xml.transform.Templates;


// public class Command{
// private Player player;
// private Scanner scanner = new Scanner (System.in);
// public Command(Player player, Map map){
// this.player=player;
// this.map=map;
// }

// public String interpret(String input){
// if (input==null){
// return "You need to enter a command.";
// }
// input=input.trim().toLowerCase();
// if (input.startsWith("inspect") ){
// String target =input.replace("inspect","").trim();
// }
// for (Item item: player.showInventory()){
// if (item.name.toLowerCase().equal(target)){
// return item.temDescription();
// }
// }
// for (Building building: player.showInventory()){
// if (item.name.toLowerCase().equal(target)){
// return item.getItemDescription();
// }
// }
// switch(userInput contains "inspect") && (userInput contains ListOfItems){
// case NEWSPAPER:
// System.out.println(newspaper.itemDescription);
// break;
// case EPIPEN:
// System.out.println(epipen.itemDescription);
// break;
// case ESSAY:
// System.out.println(essay.itemDescription);
// break;
// case BACKPACK:
// System.out.println(backpack.itemDescription);
// break;
// case PHOTO:
// System.out.println(photo.itemDescription);
// break;
// case CAKE:
// System.out.println(cake.itemDescription);
// break;
// }
// // Change this switch statement so the Player can only inspect the building they are currently in.
// // That means check the current coordinates of the player, and if they match the coordinates of the building then allow the description to be printed out.
// switch(input contains "inspect") && (input contains ListOfBuildings){
// case QUAD:
// System.out.println(quad.description);
// break;
// case TALBOT_HOUSE:
// System.out.println(talbotHouse.description);
// break;
// case LAMONT_DINING:
// System.out.println(lamontDining.description);
// break;
// case SEELYE_BASEMENT:
// System.out.println(seelyeBasement.description);
// break;
// case CAMPUS_CENTER:
// System.out.println(campusCenter.description);
// break;
// case COLLEGE_HALL:
// System.out.println(collegeHall.description);
// break;
// case OUTDOOR_TRACK:
// System.out.println(outdoorTrack.description);
// break;
// case CHEMISTRY_LAB:
// System.out.println(chemistryLab.description);
// break;
// case CERAMICS_BUILDING:
// System.out.println(ceramicsBuilding.description);
// break;
// }
// }
// }
/*
* accuse <NPC> still needs to be added to the code, as well as what this command does.
* go north/south/east/west still needs to be added to the code.
* talk to <NPC>, pick up <Item> and put down <Item> are all in Player.java. This means that Command.java should extend Player.java
*/



17 changes: 17 additions & 0 deletions Coordinates.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
public class Coordinates {
public double x;
public double y;

public Coordinates(int x, int y) {
this.x = x;
this.y = y;
}

public String toString() {
return "You're at (" + this.x + " , " + this.y + ")";
}

public boolean equals(Coordinates other) {
return this.x == other.x && this.y == other.y;
}
}
188 changes: 188 additions & 0 deletions Gameloop.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Gameloop {
public Player player;
private boolean ShakilaAccusedHanyu;
// private boolean StillPlaying;
public List<Building> buildings = new ArrayList<>();
public List<Item> items = new ArrayList<>();
public Gameloop(){
player= new Player();
ShakilaAccusedHanyu=false;

// 9 buildings
Building quad = new Building("Quad",
"Home to many dorms on Smith College.",
new Coordinates(0, 0));
Building talbotHouse = new Building("Talbot House",
"A dorm, where Boba used to live, so that’s why something feels off now.Hanyu is standing in the aisle. Hanyu lives in Talbot House, just like the victim! Maybe Hanyu wanted her room next year.Did the person die from regular poisoning? Did one of the suspects intentionally poison them with peanuts Do you wanna talk to Hanyu to find out? And look! there is a cake at the corner of the sofa.",
new Coordinates(0, 1));
Building campusCenter = new Building("Campus Center",
"A common place for studying and meeting with friends. Also there is a cafe.There is a newspaper on the table in the cafe.",
new Coordinates(1, 1));
Building collegeHall = new Building("College Hall",
"Home to the offices for Class Deans as well as the Student Financial Aid office.",
new Coordinates(1, 2));
Building chemistryLab = new Building("Chemistry Lab",
"Hanyu does her experiments there, but maybe she knows something about the poison that killed Boba...",
new Coordinates(2, 1));
Building lamontDining = new Building("Lamont Dining Hall",
"Lamont Dining Hall. An Allergy-free dining hall. Savannah works in Lamont Dining Hall, just like the victim. Didn’t like how lazy they were in the dining hall. Had a chance to poison the student with peanuts! Do you wanna talk to her?",
new Coordinates(0, 2));
Building seelyeBasement = new Building("Seelye Basement",
"Workplace for Student technology consultant, where Shakila works so she has access to onecards as a worker. The one card has access to any building on campus.Victim copied Shakila’s homework and accusations of plagiarism nearly got her to the honor board. Do you wanna talk to her?",
new Coordinates(1, 0));
Building outdoorTrack = new Building("Outdoor Track",
"Anjia and Boba used to meet here several times a week because running club practices here. Anjia was on the running club just like the victim. Jealous of her mile time. Do you wanna talk to her?",
new Coordinates(2, 0));
Building ceramicsBuilding = new Building("Ceramics Building",
"Ceramics Club meets in this lovely location to make pottery together.There is an essay lying on the ground with Shakila’s name on it.",
new Coordinates(2, 2));

// add the buildings into the list
buildings.add(quad);
buildings.add(talbotHouse);
buildings.add(campusCenter);
buildings.add(chemistryLab);
buildings.add(lamontDining);
buildings.add(seelyeBasement);
buildings.add(outdoorTrack);
buildings.add(collegeHall);
buildings.add(ceramicsBuilding);

// 6 items
Item newspaper = new Item("Newspaper", new Coordinates(1, 1), "Today's issue of the Sophian. Its main headline states 'Beloved Student Boba T. Slain Last Night in Talbot House!' Underneath it, there's another story about the Ceramics Club enjoying their pottery-making. Savannah is mentioned in this story.", false);
Item epipen = new Item("EpiPen", new Coordinates(0, 2), "A medication used to treat allergic reactions. It seems like Boba used this sometime ago.", false);
Item essay = new Item("Shakila's Essay", new Coordinates(2, 2), "A five-page essay. The very top of it says 'Shakila, this is the same paper that Boba give me! See me after class.'", false);
//Item backpack = new Item("Boba's Backpack", new Coordinates(1, 2), "There's a photo inside the front pocket of the backpack! You should be able to pick up this photo. Apart from that, the backpack appears to be empty.", false);
Item photo = new Item("Photo", new Coordinates(1, 2), "A nice Polaroid picture of Boba, Shakila, Anjia, Savannah, and Hanyu. But it seems like Anjia's face has been written over with black marker.", false);
Item cake = new Item("Cake", new Coordinates(0, 1), "A slice of vanilla cake on a paper plate. It doesn't seem like there are allergens in here, but you'd have to check...maybe go to the chemistry lab?", false);

// add the items into the list
items.add(newspaper);
items.add(epipen);
items.add(essay);
//items.add(backpack);
items.add(photo);
items.add(cake);
}

// NPCs
String [] shakila_d={
"Look closely at the EpiPen - it was broken! Someone messed with it so it wouldn’t work properly."
, "I was framed! I wrote the essay a few days ago and showed it to Hanyu to help me make edits. But Hanyu and Boba both lived in Talbot House. Maybe Hanyu was involved…",
"I forgot to say this earlier, but I lent Anjia my OneCard earlier, and she could access all sorts of buildings with it…"
};
NPC Shakila= new NPC("Shakila","Works in Seelye basement, and has access to every door on campus with Seelye OneCard. Victim copied Shakila’s homework and accusations of plagiarism nearly got her to the honor board.",
new ArrayList<>(Arrays.asList(shakila_d)), new Coordinates(1, 0));


String [] hanyu_d={
"I think it was Savannah! She was acting weird, asking me about peanut allergies when I don’t do food science, I do other things in Chemistry. If you want to look for Savannah I think she’s working a shift in Lamont dining hall. Also my lab is nearly over so I’m going to go back to my House."
,"Didn’t we just talk earlier? I’d like to help you more but I don’t know what else to say.","I didn’t help Boba cheat. Actually… I think Anjia hates Boba’s most because in every running race, Boba is the winner and Anjia is the runner up."
};
NPC Hanyu=new NPC("Hanyu","lives in Talbot House, just like the victim! Maybe Hanyu wanted her room next year.", new ArrayList<>(Arrays.asList(hanyu_d)),new Coordinates(2, 1));


String [] savannah_d={
"Look at the newspaper! There’s a photo of me in Ceramics Club during the night of the murder. I have to be innocent!If you don't believe me, you can go to ceramics buidling."
};
NPC Savannah= new NPC("Savannah","Works in Lamont Dining Hall, just like the victim. Didn’t like how lazy they were in the dining hall. Had a chance to poison the student with peanuts!",new ArrayList<>(Arrays.asList(savannah_d)),new Coordinates(0, 2));


String [] anjia_d={
"There is no way I will kill Boba! I always run with her and she is awesome! Now it seems like every suspect doesn't admit they are related to Boba's death. Do you wanna go to College Hall where Baba last was. "
,"We weren’t really friends when Boba passed away, but that doesn’t mean I killed her. She died from a peanut poisoning, right? I had no way of poisoning her."
};
NPC Anjia=new NPC("Anjia","Was on the running club just like the victim. Jealous of her mile time.",new ArrayList<>(Arrays.asList(anjia_d)), new Coordinates(2, 0));


public void run(){
Scanner scanner = new Scanner(System.in);
System.out.println("Hello, Detective! You have been commissioned by the Chief of Northampton Police Station to investigate a murder case at Smith College. Your initial coordinates are (1, 1), Campus Center. Please check the cheatsheet if you are confused about your location or your commands.");

while (true) {
System.out.print(">>> ");
String input = scanner.nextLine().trim();
if (input.equalsIgnoreCase("show inventory")) {
player.showInventory();
} else if (input.equals("exit")) {
System.out.println("Goodbye, detective.");
break;
} else if (input.startsWith("go ")) {
String direction = input.substring(3);
player.move(direction);
System.out.println(player.playerLocation);
} else if (input.startsWith("inspect ")) {
String playerInspect = input.substring(8);
player.inspect(playerInspect, buildings);
} else if (input.startsWith("pick up ")) {
String itemName = input.substring(8);
player.pickUp(itemName, items);
} else if (input.startsWith("put down ")) {
String itemName = input.substring(8);
player.putDown(itemName);

} else if (input.startsWith("talk to ")) {
String playerTalkTo = input.substring(8);

if (playerTalkTo.equalsIgnoreCase(Shakila.name) && player.playerLocation.equals(Shakila.location)) {
if (player.getInventory().contains(items.get(1))) {
System.out.println(Shakila.dialogue.get(0));
}
if (player.getInventory().contains(items.get(2))) {
System.out.println(Shakila.dialogue.get(1));
ShakilaAccusedHanyu=true;
}
if (player.getInventory().containsAll(items)) {
System.out.println(Shakila.dialogue.get(2));
}
} else if (playerTalkTo.equalsIgnoreCase(Hanyu.name)) {
if (player.playerLocation.equals(buildings.get(3).location)) {
System.out.println(Hanyu.dialogue.get(0));
} else if (player.playerLocation.equals(buildings.get(1).location)) {
if (!ShakilaAccusedHanyu) {
System.out.println(Hanyu.dialogue.get(1));
} else {
System.out.println(Hanyu.dialogue.get(2));
}
}
} else if (playerTalkTo.equalsIgnoreCase(Savannah.name)&& player.playerLocation.equals(Savannah.location)) {
System.out.println(Savannah.dialogue.get(0));
} else if (playerTalkTo.equalsIgnoreCase(Anjia.name)&& player.playerLocation.equals(Anjia.location)) {
if (player.getInventory().contains(items.get(3))) {
System.out.println(Anjia.dialogue.get(1));
} else {
System.out.println(Anjia.dialogue.get(0));
}
}
} else {
System.out.println("I don't understand that command.");
}
if (input.equalsIgnoreCase("The murderer is Anjia") && player.getInventory().containsAll(items)) {
System.out.println("Anjia was taken to the police station for questioning. Faced with your reasoning and sufficient evidence, she confessed to the crime. Congratulations, case solved!");
}
}

scanner.close();

}
public static void main(String[] args) {
Gameloop murderMystery = new Gameloop();
murderMystery.run();
}

}










13 changes: 13 additions & 0 deletions Item.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Item {
String itemName;
String itemDescription;
boolean hasBeenPickedUp;
Coordinates itemLocation;

public Item(String itemName, Coordinates itemLocation, String itemDescription, boolean hasBeenPickedUp){
this.itemName = itemName;
this.itemLocation = itemLocation;
this.itemDescription = itemDescription;
this.hasBeenPickedUp = hasBeenPickedUp;
}
}
15 changes: 15 additions & 0 deletions NPC.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import java.util.ArrayList;
public class NPC{
public String name;
public String description;
public ArrayList<String> dialogue;
public Coordinates location;

public NPC(String name,String description,ArrayList<String> dialogue, Coordinates location){
this.name=name;
this.description=description;
this.dialogue=dialogue;
this.location= location;
}

}
Loading