diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..a4fbbe64 Binary files /dev/null and b/.DS_Store differ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..19d9aa74 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "java.project.referencedLibraries": [ + "lib/**/*.jar", + "guava-31.1-jre.jar" + ] +} \ No newline at end of file diff --git a/BingoCard.java b/BingoCard.java new file mode 100644 index 00000000..d02eaae6 --- /dev/null +++ b/BingoCard.java @@ -0,0 +1,130 @@ +import java.util.ArrayList; +import java.util.Collections; +/** + * BingoCard class creates a random bingo card for a user + */ +public class BingoCard { + ArrayList < Task > tasks; + private Person owner; + private boolean bingo; + private MapGame map; + Task task1 = new Task("Borrow 'Macbeth' from Forbes Library"); + Task task2 = new Task("Buy Uggs at Synergy "); + Task task3 = new Task("Buy a coffee at Woodstar "); + Task task4 = new Task("Buy a top at Urban Outfitters "); + Task task5 = new Task("Buy a loaf of bread at Hungry Ghost "); + Task task6 = new Task("Find a ticket at Academy of Music "); + Task task7 = new Task("Get a plant from Botanic Garden "); + Task task8 = new Task("Get a postcard from the SCAM "); + Task task9 = new Task("Buy Dumplings from T.ROOTS "); + + /** + * Constructor for BingoCard class + * @param owner Person, the owner of the bingo card + */ + public BingoCard(Person owner) { + this.owner = owner; + tasks = new ArrayList < > (); + map = new MapGame(); + //format the tasks so that the strings are all the same length + //add tasks to arraylist + tasks.add(task1); + tasks.add(task2); + tasks.add(task3); + tasks.add(task4); + tasks.add(task5); + tasks.add(task6); + tasks.add(task7); + tasks.add(task8); + tasks.add(task9); + //shuffle the arraylist of tasks + Collections.shuffle(tasks); + bingo = false; + + } + /** + * Setter for bingo boolean (sets true) + */ + public void setBingoTrue() { + this.bingo = true; + } + /** + * Prints the bingo card in a 3x3 grid with a check or an x next to each task description indicating the completion status + */ + public void printBingoCard() { + System.out.println(" -----------BINGO CARD-----------"); + System.out.println(tasks.get(0).getDescription() + " " + tasks.get(0).printStatus() + " | " + tasks.get(1).getDescription() + " " + tasks.get(1).printStatus() + " | " + tasks.get(2).getDescription() + " " + tasks.get(2).printStatus()); + System.out.println(tasks.get(3).getDescription() + " " + tasks.get(3).printStatus() + " | " + tasks.get(4).getDescription() + " " + tasks.get(4).printStatus() + " | " + tasks.get(5).getDescription() + " " + tasks.get(5).printStatus()); + System.out.println(tasks.get(6).getDescription() + " " + tasks.get(6).printStatus() + " | " + tasks.get(7).getDescription() + " " + tasks.get(7).printStatus() + " | " + tasks.get(8).getDescription() + " " + tasks.get(8).printStatus()); + } + + /** + * Prints the descriptions of each task in the arraylist of tasks + */ + public void printTasks() { + for (int i = 0; i < 9; i++) { + System.out.println(tasks.get(i).getDescription()); + } + } + /** + * Checks if the person has scored a bingo based on whether or not they have completed tasks that make three in a row for their bingo card + * @return boolean bingo, true if the owner of the card has scored a bingo and false if not + */ + public boolean checkBingo() { + if (tasks.get(0).getCompletionStatus() == true && tasks.get(1).getCompletionStatus() == true && tasks.get(2).getCompletionStatus() == true) { + this.bingo = true; + System.out.println("Checking first row... " + this.bingo); + //second row + } else if (tasks.get(3).getCompletionStatus() == true && tasks.get(4).getCompletionStatus() == true && tasks.get(5).getCompletionStatus() == true) { + this.bingo = true; + System.out.println("Checking second row... " + this.bingo); + //third row + } else if (tasks.get(6).getCompletionStatus() == true && tasks.get(7).getCompletionStatus() == true && tasks.get(8).getCompletionStatus() == true) { + this.bingo = true; + System.out.println("Checking third row... " + this.bingo); + //first column + } else if (tasks.get(0).getCompletionStatus() == true && tasks.get(3).getCompletionStatus() == true && tasks.get(6).getCompletionStatus() == true) { + this.bingo = true; + System.out.println("Checking first column... " + this.bingo); + //second column + } else if (tasks.get(1).getCompletionStatus() == true && tasks.get(4).getCompletionStatus() == true && tasks.get(7).getCompletionStatus() == true) { + this.bingo = true; + System.out.println("Checking second column... " + this.bingo); + //third column + } else if (tasks.get(2).getCompletionStatus() == true && tasks.get(5).getCompletionStatus() == true && tasks.get(8).getCompletionStatus() == true) { + this.bingo = true; + System.out.println("Checking third column... " + this.bingo); + //diagonal from left to right + } else if (tasks.get(0).getCompletionStatus() == true && tasks.get(4).getCompletionStatus() == true && tasks.get(8).getCompletionStatus() == true) { + this.bingo = true; + System.out.println("Checking first diagonal... " + this.bingo); + //diagonal from right to left + } else if (tasks.get(2).getCompletionStatus() == true && tasks.get(4).getCompletionStatus() == true && tasks.get(6).getCompletionStatus() == true) { + this.bingo = true; + System.out.println("Checking second diagonal... " + this.bingo); + //else no bingo + } + if (this.bingo) { + System.out.println("BINGO! You win!"); + //end game + } + return this.bingo; + } + + /* + * Main method + */ + public static void main(String args[]) { + Person victoria = new Person(20); + BingoCard myCard = new BingoCard(victoria); + myCard.task1.setCompletedTrue(); + myCard.task2.setCompletedTrue(); + myCard.task3.setCompletedTrue(); + myCard.task4.setCompletedTrue(); + myCard.task5.setCompletedTrue(); + myCard.printTasks(); + myCard.printBingoCard(); + System.out.println(myCard.checkBingo()); + } + +} \ No newline at end of file diff --git a/Building.java b/Building.java new file mode 100644 index 00000000..e4a40420 --- /dev/null +++ b/Building.java @@ -0,0 +1,175 @@ +/** + * Building class + */ +public class Building { + /* Attributes */ + protected String name; + protected String address; + protected int nFloors; + protected int activeFloor = -1; // Default value indicating we are not inside this building + protected boolean elevator; + protected Object object; + + /** + * Overloaded constructor for map game class + * @param name name of building + * @param address address of building + */ + public Building(String name, String address) { + this.name = name; + this.address = address; + } + + /* Constructor */ + /** + * Constructor + * @param name name of building + * @param address address of building + * @param nFloors number of floors + * @param elevator whether or not there is an elevator + */ + public Building(String name, String address, int nFloors, boolean elevator) { + if (name != null) { + this.name = name; + } + if (address != null) { + this.address = address; + } + if (nFloors < 1) { + throw new RuntimeException("Cannot construct a building with fewer than 1 floor."); + } + this.nFloors = nFloors; + this.elevator = elevator; + } + + /* Accessors */ + + /** + * Getter for name + * @return name + */ + public String getName() { + return this.name; + } + + /** + * Getter for address + * @return address + */ + public String getAddress() { + return this.address; + } + + /** + * Getter for number of floors + * @return number of floors + */ + public int getFloors() { + return this.nFloors; + } + + /** + * Getter for whether or not there is an elevator + * @return whether or not there is an elevator + */ + public boolean getElevator() { + return this.elevator; + } + + /* Navigation methods */ + /** + * Lets user enter building + * @return building user is in + */ + public Building enter() { + if (activeFloor != -1) { + throw new RuntimeException("You are already inside this Building."); + } + this.activeFloor = 1; + System.out.println("You are now inside " + this.name + " on the ground floor."); + return this; // Return a pointer to the current building + } + + /** + * Lets user exit building + * @return building user exited + */ + public Building exit() { + if (this.activeFloor == -1) { + throw new RuntimeException("You are not inside this Building. Must call enter() before exit()."); + } + if (this.activeFloor > 1) { + throw new RuntimeException("You have fallen out a window from floor #" + this.activeFloor + "!"); + } + System.out.println("You have left " + this.name + "."); + this.activeFloor = -1; // We're leaving the building, so we no longer have a valid active floor + return null; // We're outside now, so the building is null + } + + /** + * Lets user go to floor + * @param floorNum floor number + */ + public void goToFloor(int floorNum) { + if (this.activeFloor == -1) { + throw new RuntimeException("You are not inside this Building. Must call enter() before navigating between floors."); + } + if (floorNum < 1 || floorNum > this.nFloors) { + throw new RuntimeException("Invalid floor number. Valid range for this Building is 1-" + this.nFloors + "."); + } + System.out.println("You are now on floor #" + floorNum + " of " + this.name); + this.activeFloor = floorNum; + } + + /** + * Lets user go up + */ + public void goUp() { + this.goToFloor(this.activeFloor + 1); + } + + /** + * Lets user go down + */ + public void goDown() { + this.goToFloor(this.activeFloor - 1); + } + + /** + * Prints options at that building + */ + public void showOptions() { + System.out.println("Available options at " + this.name + ":\n + enter() \n + exit() \n + goUp() \n + goDown()\n + goToFloor(n)"); + } + + /** + * Returns the string of name + * @return name + */ + public String toString() { + return this.name; + } + + /** + * Main Method + * @param args + */ + public static void main(String[] args) { + System.out.println("------------------------------------"); + System.out.println("Test of Building constructor/methods"); + System.out.println("------------------------------------"); + + Building fordHall = new Building("Ford Hall", "100 Green Street Northampton, MA 01063", 20, true); + System.out.println(fordHall); + fordHall.showOptions(); + + System.out.println("-----------------------------------"); + System.out.println("Demonstrating enter/exit/navigation"); + System.out.println("-----------------------------------"); + fordHall.enter(); + fordHall.goUp(); + fordHall.goDown(); + fordHall.exit(); + } + +} \ No newline at end of file diff --git a/CSC 120 FP Architecture Diagram.pdf b/CSC 120 FP Architecture Diagram.pdf new file mode 100644 index 00000000..6070cd0c Binary files /dev/null and b/CSC 120 FP Architecture Diagram.pdf differ diff --git a/CSC120 Additional reflection questions .md b/CSC120 Additional reflection questions .md new file mode 100644 index 00000000..81433545 --- /dev/null +++ b/CSC120 Additional reflection questions .md @@ -0,0 +1,26 @@ +* **What was your overall approach to tackling this project?** + +We firstly draft a narrative of the game so that we can decide what class and method we need to put in our game. Since we did this project in teamwork, it became clear to divide the workload based on different classes/methods. The underlying intention of the game was to apply the concepts we have learnt in the class over the semester, so when we were deciding the methods, we took past assignments as a reference. + +* **What new thing(s) did you learn / figure out in completing this project?** + +One of the biggest accomplishments of the game is the application of Guava. Guava helped us to build an indirect map as well as the key of the whole layout of the game. We learnt how to add information (e.g.directions) on the edges and link all the classes and methods together in the Game Loop. + +* **Is there anything that you wish you had implemented differently?** + +We could have implemented the makeResponse() method in the chatbot class a bit differently. Our approach was a bit procedural, and it could have been broken up into several methods for clarity. In a similar vein, we could have also made the instances of Object included in the game attributes of the buildings rather than the map, so that we could have removed some of the error-handling from the chatbot. + +* **If you had unlimited time, what additional features would you implement?** + +If we had unlimited time to work on this project, we’d love to implement graphics to make the game more interesting to the user. In addition, it would be great to have items sold by restaurants be instances of a class that is different than object, since it would give us more functionality with regards to the methods in the Restaurant class (we chose to just use Store to save time). We also wish we could have implemented a method called lookAround(), which would tell the player which buildings surrounded them. Finally, Northampton has a lot to do, and we could have captured more buildings and objects in our game with more time\! + +* **What was the most helpful piece of feedback you received while working on your project? Who gave it to you?** + +We received a lot of really good feedback on this project\! For instance, Professor Mosca advised us to add a class for Tasks, since each task had to hold a lot of information in order to work as implemented, and we found this to be really helpful. + +* **If you could go back in time and give your past self some advice about this project, what hints would you give?** + If we could go back in time, we would have given ourselves the hint to give ourselves a lot of time to figure out how Guava works and to not be intimidated by Guava because once you figure it out, it’s not that complicated. +* ***If you worked with a team:*** **please comment on how your team dynamics influenced your experience working on this project.** + +Our project consists of different classes. We decided that each individual in the group would be responsible for writing one part of the project (e.g. buildings, person, bingo card, map) and then we could meet to connect the classes and write the game loop. By having something to do both individually and as a group, each person could get a sense of what they should do and have a chance to collaborate with each other. This kind of working strategy made the division of the work and communication within the group much clearer. Overall, the team dynamics made everyone have a good experience on this project. + diff --git a/CSC120-FinalProject-1.code-workspace b/CSC120-FinalProject-1.code-workspace new file mode 100644 index 00000000..5281cfd4 --- /dev/null +++ b/CSC120-FinalProject-1.code-workspace @@ -0,0 +1,16 @@ +{ + "folders": [ + { + "path": "." + }, + { + "path": "../Guava Demo-20241202/.vscode" + } + ], + "settings": { + "java.project.referencedLibraries": [ + "lib/**/*.jar", + "guava-31.1-jre.jar" + ] + } +} \ No newline at end of file diff --git a/CSC210_final_project_map.pdf b/CSC210_final_project_map.pdf new file mode 100644 index 00000000..9a3656f3 Binary files /dev/null and b/CSC210_final_project_map.pdf differ diff --git a/Chatbot.java b/Chatbot.java new file mode 100644 index 00000000..cf34e368 --- /dev/null +++ b/Chatbot.java @@ -0,0 +1,330 @@ +import java.util.Scanner; +import java.util.ArrayList; + +/** + * stub for chatbot class + */ +public class Chatbot { + //attributes + String responseString; + Scanner userResponseScanner; + int numWordsReplaced; + String userInputString; + ArrayList < String > wordArrayList; + String[] wordArray; + Person chatter; + MapGame map; + BingoCard card; + + /** + * Constructor for chatbot class + * @param chatter person to whom the chatbot belongs + * @param map map to which the chatbot belongs + * @param card bingo card that belongs to the chatbot's owner + */ + public Chatbot(Person chatter, MapGame map, BingoCard card) { + this.responseString = ""; + userResponseScanner = new Scanner(System.in); + numWordsReplaced = 0; + this.chatter = chatter; + this.map = map; + this.card = card; + wordArrayList = new ArrayList < > (); + } + + /** + * Method to print a greeting to welcome the character when they spawn on the map + */ + public void printGreeting() { + System.out.println("Welcome to Northampton!"); + System.out.println("You are currently at the PVTA bus stop outside of JMG at Smith College. There is a bus driver in front of you holding a letter, and town lies to the north of you."); + System.out.println("Here is your bingo card... you must buy items to get you bingo on your card, with a limited amount of money..."); + System.out.println("Enter a command to make your next move. May the odds be ever in your favor..."); + } + + /** + * Method to get the user's input + * @return the user's input as a string + */ + public String getInput() { + return this.userInputString = userResponseScanner.nextLine(); + } + + /** + * Method to make a response based on what the user input. Evaluates a series of if statements to decide what to do, and calls methods based on recognized words. + * @return a response to what the person entered + */ + public String makeResponse() { + wordArray = this.userInputString.split(" "); + for (String a: wordArray) { + //remove spaces and line returns and turn it all into lowercase + a.trim(); + a.toLowerCase(); + wordArrayList.add(a); + } + //evaluate if the word in the array matches one of the hit words + if (wordArrayList.contains("walk") && wordArrayList.contains("north")) { //check for walk north + map.move("North"); + this.responseString = "Done!"; + } else if (wordArrayList.contains("walk") && wordArrayList.contains("south")) { //check for north + //walk method with south direction + this.map.move("South"); + this.responseString = "Done!"; + } else if (wordArrayList.contains("walk") && wordArrayList.contains("east")) { //check for east + //walk method with east direction + this.map.move("East"); + this.responseString = "Done!"; + } else if (wordArrayList.contains("walk") && wordArrayList.contains("west")) { //check for west + //walk method with west direction + this.map.move("West"); + this.responseString = "Done!"; + } else if (wordArrayList.contains("walk")) { //check for just walk with no direction + this.responseString = "What direction would you like to walk in? Please enter 'walk' and the direction."; + + } else if (wordArrayList.contains("grab") && wordArrayList.contains("uggs")) { //check grab on obj 1 + //call grab on uggs if at appropriate location + if (map.getCurrentLocation() == map.synergy) { + chatter.grab(map.uggs); + this.responseString = "..."; + } else { + this.responseString = "You aren't at synergy"; + } + } else if (wordArrayList.contains("grab") && wordArrayList.contains("coffee")) { //call grab on the appropriate object + //call grab on coffee + if (map.getCurrentLocation() == map.woodstar) { + chatter.grab(map.coffee); + this.responseString = "..."; + } else { + this.responseString = "You aren't at woodstar"; + } + } else if (wordArrayList.contains("grab") && wordArrayList.contains("top")) { //call grab on the appropriate object + //call grab on top + if (map.getCurrentLocation() == map.uo) { + chatter.grab(map.top); + this.responseString = "..."; + } else { + this.responseString = "You aren't at Urban Outfitters"; + } + } else if (wordArrayList.contains("grab") && wordArrayList.contains("loaf") || wordArrayList.contains("grab") && wordArrayList.contains("bread")) { //call grab on the appropriate object + //call grab on loaf + if (map.getCurrentLocation() == map.bread) { + chatter.grab(map.loaf); + this.responseString = "..."; + } else { + this.responseString = "You aren't at Hungry Ghost Bread"; + + } + } else if (wordArrayList.contains("grab") && wordArrayList.contains("ticket")) { //call grab on the appropriate object + //call grab on obj 5 + if (map.getCurrentLocation() == map.music) { + chatter.grab(map.ticket); + card.task6.setCompletedTrue(); + this.responseString = "..."; + } else { + this.responseString = "You aren't at Academy of Music"; + } + } else if (wordArrayList.contains("grab") && wordArrayList.contains("plant")) { //call grab on the appropriate object + //call grab on obj 6 + if (map.getCurrentLocation() == map.garden) { + chatter.grab(map.plant); + card.task7.setCompletedTrue(); + this.responseString = "..."; + } else { + this.responseString = "You aren't at Botanic Garden"; + } + } else if (wordArrayList.contains("grab") && wordArrayList.contains("postcard")) { //call grab on the appropriate object + // call grab on postcard + if (map.getCurrentLocation() == map.scam) { + chatter.grab(map.postcard); + this.responseString = "..."; + } else { + this.responseString = "You aren't at SCAM"; + + } + } else if (wordArrayList.contains("grab") && wordArrayList.contains("dumplings")) { //call grab on the appropriate object + //call grab on dumplings + if (map.getCurrentLocation() == map.troots) { + chatter.grab(map.dumplings); + this.responseString = "..."; + } else { + this.responseString = "You aren't at T.ROOTS"; + + } + } else if (wordArrayList.contains("grab") && wordArrayList.contains("macbeth")) { //call grab on the appropriate object + //call grab on macbeth + if (map.getCurrentLocation() == map.forbes) { + this.responseString = "You need to borrow it not grab it"; + } else { + this.responseString = "You aren't at Forbes"; + + } + } else if (wordArrayList.contains("grab")) { //check for grab without a specified object + this.responseString = "What object would you like to grab?"; + + //buy branch + } else if (wordArrayList.contains("buy") && wordArrayList.contains("uggs")) { //check for buy uggs + //call buy on uggs + if (map.getCurrentLocation() == map.synergy) { + map.synergy.sellGoods(map.uggs); + chatter.buy(map.uggs); + card.task2.setCompletedTrue(); + this.responseString = "..."; + } else { + this.responseString = "You aren't at synnergy"; + } + } else if (wordArrayList.contains("buy") && wordArrayList.contains("coffee")) { //call buy on the appropriate object + //call buy on coffee + if (map.getCurrentLocation() == map.woodstar) { + map.woodstar.sellGoods(map.coffee); + chatter.buy(map.coffee); + card.task3.setCompletedTrue(); + this.responseString = "..."; + } else { + this.responseString = "You aren't at woodstar"; + } + } else if (wordArrayList.contains("buy") && wordArrayList.contains("top")) { //call buy on the appropriate object + //call buy on top + if (map.getCurrentLocation() == map.uo) { + map.uo.sellGoods(map.top); + chatter.buy(map.top); + card.task4.setCompletedTrue(); + this.responseString = "..."; + } else { + this.responseString = "You aren't at Urban Outfitters"; + } + } else if (wordArrayList.contains("buy") && wordArrayList.contains("loaf") || wordArrayList.contains("buy") && wordArrayList.contains("bread")) { //call buy on the appropriate object + //call buy on loaf + if (map.getCurrentLocation() == map.bread) { + map.bread.sellGoods(map.loaf); + chatter.buy(map.loaf); + card.task5.setCompletedTrue(); + this.responseString = "..."; + } else { + this.responseString = "You aren't at Urban Outfitters"; + } + } else if (wordArrayList.contains("buy") && wordArrayList.contains("ticket")) { //call buy on the appropriate object + //call buy on ticket + if (map.getCurrentLocation() == map.music) { + map.bread.sellGoods(map.ticket); + chatter.buy(map.ticket); + card.task5.setCompletedTrue(); + this.responseString = "..."; + } else { + this.responseString = "You aren't at the Academy of Music"; + } + } else if (wordArrayList.contains("buy") && wordArrayList.contains("plant")) { //call buy on the appropriate object + //call buy on plant + if (map.getCurrentLocation() == map.garden) { + map.bread.sellGoods(map.plant); + chatter.buy(map.plant); + card.task5.setCompletedTrue(); + this.responseString = "..."; + } else { + this.responseString = "You aren't at the Botanic Garden"; + } + } else if (wordArrayList.contains("buy") && wordArrayList.contains("macbeth")) { //call buy on the appropriate object + //call buy on macbeth + if (map.getCurrentLocation() == map.forbes) { + map.bread.sellGoods(map.macbeth); + chatter.buy(map.macbeth); + card.task5.setCompletedTrue(); + this.responseString = "..."; + } else { + this.responseString = "You aren't at Forbes"; + } + } else if (wordArrayList.contains("buy") && wordArrayList.contains("postcard")) { //call buy on the appropriate object + //call buy on postcard + if (map.getCurrentLocation() == map.scam) { + map.scam.sellGoods(map.postcard); + chatter.buy(map.postcard); + card.task8.setCompletedTrue(); + this.responseString = "..."; + } else { + this.responseString = "You aren't at Smith College Art Museum"; + } + } else if (wordArrayList.contains("buy") && wordArrayList.contains("dumplings")) { //call buy on the appropriate object + //call buy on dumplings + if (map.getCurrentLocation() == map.troots) { + map.troots.sellGoods(map.dumplings); + chatter.buy(map.dumplings); + card.task9.setCompletedTrue(); + this.responseString = "..."; + } else { + this.responseString = "You aren't at T. Roots"; + } + } else if (wordArrayList.contains("buy")) { //check for buy without a specified object + this.responseString = "What would you like to buy?"; + + //check bingo branch + } else if (wordArrayList.contains("check") && wordArrayList.contains("bingo")) { //check to see if they want to check their bingo + this.card.checkBingo(); + this.card.printBingoCard(); + this.responseString = "Done!"; + + //borrow/return book branch + } else if (wordArrayList.contains("borrow") && wordArrayList.contains("macbeth")) { //check to see if they want to borrow a library book + if (map.getCurrentLocation() == map.forbes) { + this.map.forbes.checkOut(map.macbeth); + this.chatter.getInventory().add(map.macbeth); + card.task1.setCompletedTrue(); + this.responseString = "Done!"; + } else { + this.responseString = "You aren't at the library!"; + } + + } else if (wordArrayList.contains("borrow")) { + this.responseString = "What title would you like to borrow? Please enter 'borrow' followed by the title."; + } else if (wordArrayList.contains("return") && wordArrayList.contains("macbeth")) { //check to see if they want to return a library book + //call return on the title + if (map.getCurrentLocation() == map.forbes) { + this.map.forbes.returnBook(map.macbeth); + this.responseString = "Done!"; + } else { + this.responseString = "You aren't at the library!"; + } + this.responseString = "Done!"; + + } else if (wordArrayList.contains("return")) { + this.responseString = "What title would you like to return?"; + + //help branch + } else if (wordArrayList.contains("help")) { + this.responseString = "Commands\n- walk (direction)\n" + // + "- buy (object)\n" + // + "- grab (object)\n" + // + "- check bingo\n" + // + "- borrow (book title)\n" + // + "- return (book title)\n- end game"; + + //end game branch + } else if (wordArrayList.contains("end") && wordArrayList.contains("game")) { + card.setBingoTrue(); + this.responseString = "goodbye!"; + } else { + this.responseString = "I don't know that word"; + } + wordArrayList.clear(); + + return this.responseString; + + } + + /** + * Main Method + * @param arguments + */ + public static void main(String[] arguments) { + boolean play = true; + Person victoria = new Person(0); + BingoCard myCard = new BingoCard(victoria); + MapGame map = new MapGame(); + Chatbot chatbot = new Chatbot(victoria, map, myCard); + chatbot.printGreeting(); + //map.move("North"); + while (play) { + chatbot.getInput(); + System.out.println(chatbot.makeResponse()); + } + + } +} \ No newline at end of file diff --git a/Gameloop.java b/Gameloop.java new file mode 100644 index 00000000..8060d1a4 --- /dev/null +++ b/Gameloop.java @@ -0,0 +1,34 @@ +/** + * Gameloop + */ +public class Gameloop { + private Person player; + private MapGame map; + static BingoCard bingo; + private Chatbot chat; + + /** + * Constructor + */ + public Gameloop() { + this.player = new Person(200); // initialize player with $200 + this.map = new MapGame(); // initializes new map + this.bingo = new BingoCard(player); // initializes new bingo card for player + this.chat = new Chatbot(player, map, bingo); // initializes new chatbot + } + + /** + * Main Method + * @param args + */ + public static void main(String args[]) { + Gameloop loop = new Gameloop(); + loop.chat.printGreeting(); + bingo.printBingoCard(); + while (bingo.checkBingo() == false) { + loop.chat.getInput(); + System.out.println(loop.chat.makeResponse()); + } + System.out.println("You have won the game!"); + } + } \ No newline at end of file diff --git a/Library.java b/Library.java new file mode 100644 index 00000000..b3587dc3 --- /dev/null +++ b/Library.java @@ -0,0 +1,110 @@ +import java.util.ArrayList; +import java.util.Hashtable; + +/** + * Library Class + */ +public class Library extends Building { + + // Attributes + private Hashtable < Object, Boolean > collection; + + /** + * Constructor + * @param name name of library + * @param address address of library + */ + public Library(String name, String address) { + super(name, address); + collection = new Hashtable < Object, Boolean > (); + } + + // Methods + /** + * This an overloaded method(addTittle) to add one book to the collection each time we call it. + * @param title the title of the book we want to add + */ + public void addTitle(Object title) { + collection.put(title, true); + } + + /** + * This an overloaded method(addTittle) to add a list of books to the collection each time we call it. + * @param titles the lists of books we want to add + */ + public void addTitle(ArrayList < Object > titles) { + for (int i = 0; i < titles.size(); i++) { + collection.put(titles.get(i), true); + } + } + + /** + * This method removes books from the collection + * @param title the title of the book we want to remove + * @return string, the title that we removed + */ + public Object removeTitle(Object title) { + collection.remove(title); + return title; + } + + /** + * This method modify the value associated with the given key (he title) to false when a book is checked out. + * @param title the book that is checked out + */ + public void checkOut(Object title) { + collection.replace(title, false); + System.out.println("Borrrowed " + title.getName()); + } + + /** + * This method modify the value associated with the given key (he title) to true when a book is returned. + * @param title the book that is returned + */ + public void returnBook(Object title) { + collection.replace(title, true); + } + + /** + * This method checks whether a book is in the collection. + * @param title the book we want to check + * @return boolean, true if the title appears as a key in the Libary's collection, false otherwise + */ + public boolean containsTitle(Object title) { + return collection.containsKey(title); + } + + /** + * This method checks whether a book is available. + * @param title the book we want to check + * @return boolean, true if the title is currently available, false otherwise + */ + public boolean isAvailable(Object title) { + return collection.get(title); + } + + /** + * This method prints out the entire collection in an easy-to-read way (including checkout status). + */ + public void printCollection() { + System.out.println(collection.toString()); + } + + /** + * This method overrides the showOptions() method in the parent class(Building) to reflect the subclass-specific options for Library class. + */ + @Override + public void showOptions() { + System.out.println("Available options at " + this.name + ":\n + enter() \n + exit() \n + goUp() \n + goDown()\n + goToFloor(n)\n + addTitle()\n + removeTitle()\n + checkOut()\n + returnBook()\n + containsTitle()\n + isAvailable()\n + printCollection()"); + } + + /** + * This method overrides the goToFloor() method in the parent class(Building) to allow movement between non-adjacent floors. + * @param n floor number + */ + @Override + public void goToFloor(int n) { + super.goToFloor(n); + } + +} \ No newline at end of file diff --git a/MapGame.java b/MapGame.java new file mode 100644 index 00000000..aad19a56 --- /dev/null +++ b/MapGame.java @@ -0,0 +1,391 @@ +import com.google.common.graph.*; +import java.util.HashMap; +import java.util.Map; +import java.util.Scanner; +/** + * Class for each instance of the Northampton map + */ +public class MapGame{ + private HashMap> directions; // stores directions to get to buildings + private MutableGraph mapGraph; // graph + + // Buildings + private Building pvta; + private Building currentLocation; + public Store synergy; + public Store woodstar; + public Store bread; + private Building thornes; + public Building music; + public Store uo; + private Building mosaic; + private Building policeStation; + public Library forbes; + private Building pulaski; + private Building cityHall; + private Building cedarChest; + public Store troots; + private Building bass; + public Building garden; + public Store scam; + private Building smithGate; + + //Objects + Object macbeth; + Object uggs; + Object coffee; + Object top; + Object loaf; + Object ticket; + Object plant; + Object postcard; + Object dumplings; + + + +/** + * Constructor + */ + public MapGame(){ + pvta = new Building("PVTA Station", "Elm Street at Prospect Street"); + this.currentLocation = pvta; // sets current location to pvta + directions = new HashMap<>(); + // create graph + mapGraph = GraphBuilder.undirected().build(); + // make instances of buildings + synergy = new Store("Synergy", "2 Tyler Ct"); + woodstar = new Store("Woodstar Cafe", "46 College Ln"); + bread = new Store("hungry ghost bread", "44 College Ln"); + thornes = new Building("Thornes Marketplace", "150 Main St"); + music = new Building("Academy of Music", "274 Main St"); + uo = new Store("Urban Outfitters", "109 Main St"); + troots = new Store("T.ROOTS", "249 Main St"); + mosaic = new Building("Mosaic Cafe", "78 Masonic St"); + policeStation = new Building("Northampton Police Department", "29 Center St"); + forbes = new Library("Forbes Library", "20 West St"); + pulaski = new Building("Pulaski Park", "240 Main St"); + cityHall = new Building("Northampton City Hall", "210 Main St"); + cedarChest = new Building("Cedar Chest", "150 Main St"); + garden = new Building("The Botanic Garden of Smith College", "16 College Ln"); + bass = new Building("Bass Hall", "4 Tyler Ct"); + scam = new Store("Smith College Museum of Art", "20 Elm St"); + smithGate = new Building("Smith College Gate", "20 Elm St"); + // add nodes and adges to buildings + this.addNodesEdges(); + this.directions(); + + // create instances of objects + macbeth = new Object("macbeth"); + forbes.addTitle(macbeth); + uggs = new Object("uggs", 150); + synergy.addGoods(uggs); + coffee = new Object("coffee",5); + woodstar.addGoods(coffee); + top = new Object("top", 10); + uo.addGoods(top); + loaf = new Object("hungry ghost bread",7); + bread.addGoods(loaf); + ticket = new Object("ticket"); + plant = new Object("plant"); + postcard = new Object("postcard", 5); + scam.addGoods(postcard); + dumplings = new Object("dumplings", 7); + troots.addGoods(dumplings); + + + } + + /** + * Getter for current location + * @return current location + */ + public Building getCurrentLocation(){ + return this.currentLocation; + } + + public Building move(String direction){ + if (direction.equalsIgnoreCase("Restart")) { + currentLocation = pvta; + System.out.println("Restarting... You are back at: " + currentLocation.name); + } else { + Map possibleMoves = directions.get(currentLocation.name); + if (possibleMoves != null && possibleMoves.containsKey(direction)) { + currentLocation = possibleMoves.get(direction); + + System.out.println("\nYou moved " + direction + " to: " + currentLocation.name); + } else { + System.out.println("Building not found! Try again."); + + } + + + } + return currentLocation; + + } + + /** + * Adds nodes and edges between building instances + */ + public void addNodesEdges(){ + mapGraph.addNode(pvta); + mapGraph.addNode(bread); + mapGraph.addNode(troots); + mapGraph.addNode(woodstar); + mapGraph.addNode(mosaic); + + //nodes for the store area + mapGraph.addNode(music); + mapGraph.addNode(thornes); + mapGraph.addNode(uo); + mapGraph.addNode(synergy); + mapGraph.addNode(cedarChest); + + //nodes for city hall area + mapGraph.addNode(cityHall); + mapGraph.addNode(forbes); + mapGraph.addNode(pulaski); + mapGraph.addNode(policeStation); + + //nodes for smith college area + mapGraph.addNode(smithGate); + mapGraph.addNode(bass); + mapGraph.addNode(scam); + mapGraph.addNode(policeStation); + + + //edges for the restaurant area + mapGraph.putEdge(pvta, bread); + mapGraph.putEdge(bread, woodstar); + mapGraph.putEdge(bread, troots); + mapGraph.putEdge(bread, mosaic); + mapGraph.putEdge(bread, thornes); + mapGraph.putEdge(troots, bread); + mapGraph.putEdge(troots, mosaic); + mapGraph.putEdge(mosaic, troots); + mapGraph.putEdge(troots, woodstar); + mapGraph.putEdge(mosaic, thornes); + + //edges for the store area + mapGraph.putEdge(music, cedarChest); + mapGraph.putEdge(music, thornes); + mapGraph.putEdge(music, uo); + mapGraph.putEdge(thornes, bread); + mapGraph.putEdge(thornes, mosaic); + mapGraph.putEdge(thornes, uo); + mapGraph.putEdge(thornes, mosaic); + mapGraph.putEdge(thornes, synergy); + mapGraph.putEdge(cedarChest, thornes); + mapGraph.putEdge(cedarChest, music); + mapGraph.putEdge(cedarChest, uo); + mapGraph.putEdge(cedarChest, synergy); + mapGraph.putEdge(uo, music); + mapGraph.putEdge(uo, cedarChest); + mapGraph.putEdge(uo, thornes); + mapGraph.putEdge(uo, synergy); + mapGraph.putEdge(synergy, cedarChest); + mapGraph.putEdge(synergy, uo); + mapGraph.putEdge(synergy, thornes); + + //edges for the smith college area + mapGraph.putEdge(bass, garden); + mapGraph.putEdge(bass, scam); + mapGraph.putEdge(bass, smithGate); + mapGraph.putEdge(garden, scam); + mapGraph.putEdge(garden, bass); + mapGraph.putEdge(garden, smithGate); + mapGraph.putEdge(scam, garden); + mapGraph.putEdge(scam, bass); + mapGraph.putEdge(scam, smithGate); + mapGraph.putEdge(smithGate, bass); + mapGraph.putEdge(smithGate, scam); + mapGraph.putEdge(smithGate, garden); + + + //edges for the city hall area + mapGraph.putEdge(cityHall, pvta); + mapGraph.putEdge(cityHall, forbes); + mapGraph.putEdge(cityHall, policeStation); + mapGraph.putEdge(cityHall, pulaski); + mapGraph.putEdge(forbes, cityHall); + mapGraph.putEdge(forbes, policeStation); + mapGraph.putEdge(forbes, pulaski); + mapGraph.putEdge(pulaski, cityHall); + mapGraph.putEdge(pulaski, bass); + mapGraph.putEdge(scam, smithGate); + mapGraph.putEdge(smithGate, bass); + mapGraph.putEdge(smithGate, scam); + mapGraph.putEdge(smithGate, garden); + + + } + + /** + * Sets directions between buildings + */ + public void directions(){ + // Directions for PVTA Station + directions.put(pvta.name, Map.of( + "East", bread, + "North", smithGate, + "West", cityHall, + "South", music + )); + + // Directions for Hungry Ghost Bread + directions.put(bread.name, Map.of( + "West", pvta, + "South", thornes, + "East", mosaic, + "North", woodstar + )); + // Directions for Mosaic Cafe + directions.put(mosaic.name, Map.of( + "West", bread, + "East", troots, + "North", woodstar + )); + + // Directions for Woodstar Cafe + directions.put(woodstar.name, Map.of( + "South", bread, + "East", mosaic + )); + + // Directions for T.Roots + directions.put(troots.name, Map.of( + "West", mosaic + )); + + //Direction of Academy of Music + directions.put(music.name, Map.of( + "North", pvta, + "West", cedarChest, + "South", uo, + "East", thornes + )); + + //Direction of Thornes + directions.put(thornes.name, Map.of( + "North", bread, + "West", music, + "South", uo, + "East", synergy + )); + + //Direction of urban outfitters + directions.put(uo.name, Map.of( + "North", thornes, + "West", music, + "South", cedarChest, + "East", synergy + )); + //Directions for Cedar Chest + directions.put(cedarChest.name, Map.of( + "North", uo, + "South", synergy, + "East", music + )); + //Directions for Synergy + directions.put(synergy.name, Map.of( + "North", thornes, + "South", cedarChest, + "West", uo + )); + + // Directions for City Hall + directions.put(cityHall.name, Map.of( + "North", pvta, + "South", policeStation, + "East", pulaski, + "West", forbes + + )); + + // Directions for Forbes + directions.put(forbes.name, Map.of( + "South", policeStation, + "East", pulaski, + "North", cityHall + + )); + + // Directions for Pulaski Park + directions.put(pulaski.name, Map.of( + "South", policeStation, + "West", forbes, + "North", cityHall + + )); + + // Directions for Police Station + directions.put(policeStation.name, Map.of( + "North", cityHall, + "East", pulaski, + "West", forbes + + )); + + + // Directions for Smith College + directions.put(smithGate.name, Map.of( + "South", pvta, + "North", garden, + "East", scam, + "West", bass + + )); + + // Directions for Bass Hall + directions.put(bass.name, Map.of( + "North", garden, + "East", scam, + "South", smithGate + + )); + + // Directions for SCAM + directions.put(scam.name, Map.of( + "North", garden, + "South", smithGate, + "West", bass + + )); + + // Directions for Botanic Garden + directions.put(garden.name, Map.of( + "South", smithGate, + "East", scam, + "West", bass + + )); + + + + + + } + /** + * Main Method + * @param args + */ + public static void main(String args[]){ + MapGame map = new MapGame(); + map.addNodesEdges(); + map.directions(); + map.move("North"); + map.move("North"); + map.move("North"); + map.move("South"); + System.out.println(map.getCurrentLocation()); + //Object object = map.woodstar.getInventory(); + System.out.println(map.woodstar.getInventory().get(0).getName()); + } + + + + + +} + + diff --git a/Object.java b/Object.java new file mode 100644 index 00000000..2c35966f --- /dev/null +++ b/Object.java @@ -0,0 +1,42 @@ +/** + * Object Class + */ +public class Object { + private String name; // name of object + private int price; // price of object + + /** + * Overloaded Constructor that only takes name as input + * @param name name of object + */ + public Object(String name) { + this.name = name; + this.price = 0; // sets object price to 0 if not inputted + } + + /** + * Full Constructor + * @param name name of object + * @param price price of object + */ + public Object(String name, int price) { + this.name = name; + this.price = price; + } + /** + * Getter for name of object + * @return returns name of object + */ + public String getName() { + return this.name; + } + + /** + * Getter for price of object + * @return price of object + */ + public int getPrice() { + return this.price; + } + + } \ No newline at end of file diff --git a/README.md b/README.md index c1a995eb..297e97a0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# CSC120-FinalProject +# Northampton Bingo(CSC120-FinalProject) ## Deliverables: - Your final codebase @@ -10,9 +10,30 @@ ## Additional Reflection Questions - What was your **overall approach** to tackling this project? + +We firstly draft a narrative of the game so that we can decide what class and method we need to put in our game. Since we did this project in teamwork, it became clear to divide the workload based on different classes/methods. The underlying intention of the game was to apply the concepts we have learnt in the class over the semester, so when we were deciding the methods, we took past assignments as a reference. + - What **new thing(s)** did you learn / figure out in completing this project? + +One of the biggest accomplishments of the game is the application of Guava. Guava helped us to build an indirect map as well as the key of the whole layout of the game. We learnt how to add information (e.g.directions) on the edges and link all the classes and methods together in the Game Loop. + - Is there anything that you wish you had **implemented differently**? + +We could have implemented the makeResponse() method in the chatbot class a bit differently. Our approach was a bit procedural, and it could have been broken up into several methods for clarity. In a similar vein, we could have also made the instances of Object included in the game attributes of the buildings rather than the map, so that we could have removed some of the error-handling from the chatbot. + - If you had **unlimited time**, what additional features would you implement? + +If we had unlimited time to work on this project, we’d love to implement graphics to make the game more interesting to the user. In addition, it would be great to have items sold by restaurants be instances of a class that is different than object, since it would give us more functionality with regards to the methods in the Restaurant class (we chose to just use Store to save time). We also wish we could have implemented a method called lookAround(), which would tell the player which buildings surrounded them. Finally, Northampton has a lot to do, and we could have captured more buildings and objects in our game with more time! + - What was the most helpful **piece of feedback** you received while working on your project? Who gave it to you? + +We received a lot of really good feedback on this project! For instance, Professor Mosca advised us to add a class for Tasks, since each task had to hold a lot of information in order to work as implemented, and we found this to be really helpful. + - If you could go back in time and give your past self some **advice** about this project, what hints would you give? + +If we could go back in time, we would have given ourselves the hint to give ourselves a lot of time to figure out how Guava works and to not be intimidated by Guava because once you figure it out, it’s not that complicated. + - _If you worked with a team:_ please comment on how your **team dynamics** influenced your experience working on this project. + +Our project consists of different classes. We decided that each individual in the group would be responsible for writing one part of the project (e.g. buildings, person, bingo card, map) and then we could meet to connect the classes and write the game loop. By having something to do both individually and as a group, each person could get a sense of what they should do and have a chance to collaborate with each other. This kind of working strategy made the division of the work and communication within the group much clearer. Overall, the team dynamics made everyone have a good experience on this project. + diff --git a/Store.java b/Store.java new file mode 100644 index 00000000..cd854863 --- /dev/null +++ b/Store.java @@ -0,0 +1,63 @@ +import java.util.ArrayList; +/** + * Store Class + */ +public class Store extends Building { + + // Attributes + private ArrayList < Object > goodsInventory; + + /** + * Constructor + * @param name name of store + * @param address address of store + */ + public Store(String name, String address) { + super(name, address); + + this.goodsInventory = new ArrayList < Object > (); + } + + // Accessors + + /** + * Getter for goods inventory + * @return inventory of items store has + */ + public ArrayList < Object > getInventory() { + return this.goodsInventory; + + } + + // Methods + + /** + * Adds items to store's inventory + * @param object object to be added + * @return + */ + public Object addGoods(Object object) { + if (goodsInventory.contains(object)) { + throw new RuntimeException("Store already has this object and cannot add it."); + } else { + goodsInventory.add(object); + return object; + } + + } + + /** + * Removes items from store's inventory when they are sold + * @param object object to be sold + * @return object that is sold + */ + public Object sellGoods(Object object) { + if (goodsInventory.contains(object)) { + goodsInventory.remove(object); + return object; + } else { + throw new RuntimeException("Store does not have this item and cannot sell it."); + } + } + +} \ No newline at end of file diff --git a/Task.java b/Task.java new file mode 100644 index 00000000..9fd36fa1 --- /dev/null +++ b/Task.java @@ -0,0 +1,59 @@ +/** + * Class for the tasks requried to win the game + */ +public class Task { + //attributes + private String description; + private boolean completed; + String statusString; + + /** + * Constructor for the task class + * @param description what the person needs to do to complete the task + */ + public Task(String description) { + this.description = description; + this.completed = false; + this.statusString = "X"; + } + + /** + * Getter for the description of the task + * @return the description of the task + */ + public String getDescription() { + return this.description; + } + /** + * Getter for whether or not the task has been completed + * @return the boolean indicating whether or not the task has been completed + */ + public boolean getCompletionStatus() { + return this.completed; + } + /** + * Setter for whether or not the task has been completed, sets true + */ + public void setCompletedTrue() { + this.completed = true; + } + /** + * Setter for whether or not the task has been completed, sets false + */ + public void setCompletedFalse() { + this.completed = false; + } + /** + * Returns a string corresponding to whether or not the task has been completed, for printing purposes + * @return a checkmark string if the task has been completed, and an x if it has not + */ + public String printStatus() { + if (this.completed) { + statusString = "✓"; + } else { + statusString = "X"; + } + return statusString; + } + +} \ No newline at end of file diff --git a/Updated_Architecture_Diagram.pdf b/Updated_Architecture_Diagram.pdf new file mode 100644 index 00000000..25e88052 Binary files /dev/null and b/Updated_Architecture_Diagram.pdf differ diff --git a/cheatsheet.md b/cheatsheet.md index d5dc4294..44bc1f93 100644 --- a/cheatsheet.md +++ b/cheatsheet.md @@ -1,4 +1,30 @@ -This file will contain documentation for all commands available in your game. + +directions: +- north +- south +- east +- west + +objects: +- macbeth(book object) +- uggs +- coffee +- top +- loaf/bread +- ticket +- plant +- postcard +- dumplings + + +Commands: +- walk (direction) +- buy (object) +- grab (object) +- check bingo +- borrow (book title) +- return (book title) +- end game Note: It's a good idea to also make this list available inside the game, in response to a `HELP` command. @@ -6,3 +32,15 @@ Note: It's a good idea to also make this list available inside the game, in res # SPOILER ALERT If your game includes challenges that must be overcome to win, also list them below. + +The user must score three in a row on a randomly generated bingo card of tasks in order to win. The tasks are as follows: +- Buy a pair of Uggs at Synergy +- Buy a coffee at Woodstar +- Buy a postcard at the Smith College Museum of Art +- Get a plant from the Smith College Botanical Garden +- Buy a top at Urban Outfitters +- Buy a loaf at Hungry Ghost +- Get a ticket to a show at the Academy of Music +- Buy dumplings at T.ROOTS +- Check out Macbeth at Forbes Public Library + diff --git a/design_justification.md b/design_justification.md new file mode 100644 index 00000000..5d3a6dcc --- /dev/null +++ b/design_justification.md @@ -0,0 +1,3 @@ +Design Justification: + +In the current stage, our game is primarily text-based and can only operate in the terminal. It takes the player approximately over 5 minutes to know the basic operations of the game only by the texts and commands in the terminal. We considered adding a more straightforward graphical interface to operate the game which can shorten the player's ramp up time, but this wasn’t in our current skill set. Additionally, we considered adding more interesting methods and objects to make the Northampton Bingo more playable, however due to time constraints, this was not possible. diff --git a/guava-31.1-jre.jar b/guava-31.1-jre.jar new file mode 100644 index 00000000..16819229 Binary files /dev/null and b/guava-31.1-jre.jar differ diff --git a/person.java b/person.java new file mode 100644 index 00000000..d9884b5e --- /dev/null +++ b/person.java @@ -0,0 +1,99 @@ +import java.util.ArrayList; + +/** + * Person class + */ +public class Person { + private int money; + private ArrayList < Object > inventory; + + /** + * Constructor for person class + * @param money amount of money user has + */ + public Person(int money) { + this.money = money; + this.inventory = new ArrayList < Object > (); + } + + /** + * Allows user to grab object that costs no money and adds the object to their inventory if it is not already in inventory + * @param object object to be grabbed + * @return object grabbed + */ + public Object grab(Object object) { + if (inventory.contains(object)) { + System.out.println("You already have this object and cannot grab it."); + return object; + } else { + if (object.getPrice() == 0) { + inventory.add(object); + System.out.println("You have grabbed " + object.getName()); + return object; + } else { + System.out.println("This object costs money so you need to buy it."); + return null; + } + } + + } + + /** + * Allows user to buy an object that costs money and adds it to their inventory + * @param object + * @param price + * @return the amount of money user has after buying object + */ + public int buy(Object object) { + if (inventory.contains(object)) { + System.out.println("You already have this object and cannot buy it."); + return this.money; + } else { + if (object.getPrice() != 0) { + inventory.add(object); + System.out.println("You have bought " + object.getName()); + this.money = this.money - object.getPrice(); + System.out.println("You now have $" + this.money + " left after purchasing " + object.getName()); + return this.money; + } else { + System.out.println("This object is free and you can just grab it."); + return this.money; + } + } + } + + /** + * Allows user to drop an object as long as it is in their inventory + * @param object object to be dropped + * @return object + */ + public Object drop(Object object) { + if (inventory.contains(object)) { + inventory.remove(object); + return object; + } else { + throw new RuntimeException("You do not have object in your inventory."); + } + } + + /** + * Getter for inventory + * @return inventory of objects user has + */ + public ArrayList < Object > getInventory() { + return this.inventory; + + } + + /** + * Main Method + * @param args + */ + public static void main(String[] args) { + Person Bebe = new Person(200); + Object gum = new Object("gum", 3); + Bebe.buy(gum); + Bebe.grab(gum); + + } +} \ No newline at end of file diff --git a/rubric.md b/rubric.md index 8bb8f4c8..cb093868 100644 --- a/rubric.md +++ b/rubric.md @@ -1,48 +1,48 @@ ## Front-End Design (10 pts) -_____ 2 pts: Game has a **robust, understandable text-based interface** that allows the player to control their movement through the game. Player should be able to enter any command at any time, and if it makes sense in the current context it will be carried out. +_Yes____ 2 pts: Game has a **robust, understandable text-based interface** that allows the player to control their movement through the game. Player should be able to enter any command at any time, and if it makes sense in the current context it will be carried out. -_____ 2 pts: Submission includes a **cheat sheet** (`cheatsheet.md`) documenting all of the available commands, as well as a **description of the layout** of your game world's underlying physical layout; this can be described in words, or included as a separate image file if you prefer to sketch a map by hand. If your game includes **challenges** that must be overcome to win, also describe them here. +_Yes____ 2 pts: Submission includes a **cheat sheet** (`cheatsheet.md`) documenting all of the available commands, as well as a **description of the layout** of your game world's underlying physical layout; this can be described in words, or included as a separate image file if you prefer to sketch a map by hand. If your game includes **challenges** that must be overcome to win, also describe them here. -_____ 2 pts: Storyline driving the game is **engaging**, and individual elements of play make sense within the context of the story. +_Yes____ 2 pts: Storyline driving the game is **engaging**, and individual elements of play make sense within the context of the story. -_____ 2 pts: Game has **multiple possible paths / outcomes** (i.e. gameplay depends on player's choices and is not the same every time). +_Yes____ 2 pts: Game has **multiple possible paths / outcomes** (i.e. gameplay depends on player's choices and is not the same every time). -_____ 1 pt: Gameplay supports **reversible moves** where reasonable (e.g., if you pick up an object, you should be able to put it back down again later, possibly in a different place; if you go north then you should be able to return to the previous location by going south unless something has blocked your return path). +_Yes____ 1 pt: Gameplay supports **reversible moves** where reasonable (e.g., if you pick up an object, you should be able to put it back down again later, possibly in a different place; if you go north then you should be able to return to the previous location by going south unless something has blocked your return path). -_____ 1 pt: Some paths through the game have **restricted access** until the player has completed a task or acquired a specific item (i.e. a key to open a door, etc.). +_Yes____ 1 pt: Some paths through the game have **restricted access** until the player has completed a task or acquired a specific item (i.e. a key to open a door, etc.). ## Back-End Design (10 pts) -_____ 2 pts: Selected classes(s) are **effective, efficient** at supporting the desired operations and program behavior. +_Yes____ 2 pts: Selected classes(s) are **effective, efficient** at supporting the desired operations and program behavior. -_____ 2 pts: Design justification includes a discussion of at least one (reasonable) **alternative design** that could have been used, and the reasons why you decided against this alternative. +_Yes____ 2 pts: Design justification includes a discussion of at least one (reasonable) **alternative design** that could have been used, and the reasons why you decided against this alternative. -_____ 2 pts: The project makes effective use of **Java built-in classes** whenever they are appropriate. +_Yes____ 2 pts: The project makes effective use of **Java built-in classes** whenever they are appropriate. -_____ 2 pts: The project's design is **extensible** (i.e. someone else could pick up where you left off, adding on or modifying the game without requiring a total rewrite). +_Yes____ 2 pts: The project's design is **extensible** (i.e. someone else could pick up where you left off, adding on or modifying the game without requiring a total rewrite). -_____ 2 pts: Submission includes an **architecture diagram** describing the relationships between all classes. +_Yes____ 2 pts: Submission includes an **architecture diagram** describing the relationships between all classes. ## General Items (10 pts): -_____ 4 pts: Program compiles without errors or warnings. +_Yes____ 4 pts: Program compiles without errors or warnings. -_____ 2 pts: Executes fully & consistently without crashing (exception/freeze). +_Yes____ 2 pts: Executes fully & consistently without crashing (exception/freeze). -_____ 2 pt: Complies with style guidelines (missing items 1 pt each): +_Yes____ 2 pt: Complies with style guidelines (missing items 1 pt each): - _____ Classes & class members all have Javadoc header comments. + _Yes____ Classes & class members all have Javadoc header comments. - _____ Clear and consistent indentation of bracketed sections. + _Yes____ Clear and consistent indentation of bracketed sections. - _____ Adheres to Java conventions on naming & capitalization. + _Yes____ Adheres to Java conventions on naming & capitalization. - _____ Methods & variables all have clear and accurate names. + _Yes____ Methods & variables all have clear and accurate names. - _____ Methods avoid confusing side effects. + _Yes____ Methods avoid confusing side effects. -_____ 1 pt: All required files included with submission (including completed checklist file). +_Yes____ 1 pt: All required files included with submission (including completed checklist file). -_____ 1 pt: `readme.md` contains your reflection on the project and responses to all prompts . +_Yes____ 1 pt: `readme.md` contains your reflection on the project and responses to all prompts .