Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 14 commits into
base: feedback
Choose a base branch
from
Open

Feedback #1

wants to merge 14 commits into from

Conversation

github-classroom[bot]
Copy link

@github-classroom github-classroom bot commented Feb 14, 2021

👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.

In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.

Click the Files changed or Commits tab to see all of the changes pushed to master since the assignment started. Your teacher can see this too.

Notes for teachers

Use this PR to leave feedback. Here are some tips:

  • Click the Files changed tab to see all of the changes pushed to master since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.
  • Click the Commits tab to see the commits pushed to master. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.

For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @swayamr2

//Store JSON data into an AdventureDesign Object
currentDesign = mapper.readValue(file, AdventureDesign.class);
} catch (Exception e) {
System.out.println("Please try again!");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little odd that you tell the user to try again, but you don't give them the opportunity to try again.

for (Room room : rooms) {
if (room.getName().equalsIgnoreCase(currentDesign.getStartingRoom())) {
currentRoom = room;
//store beginning room name into variable startingRoom

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be consistent with comment casing

* "drop", "examine", and more. Accounts for spelling and spacing errors.
*/
public class Main {
private static AdventureDesign currentDesign;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of the name currentDesign because that implies the design could change mid-game which it won't.

//store beginning room name into variable endingRoom
endingRoom = room.getName();
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A line of whitespace would be helpful here

import java.util.Collections;

/**
* I created a static class UserMoves, containing all the moves that will be used in the main method.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just need to say what a class does in its docs, you don't need to explain why you created it

* This method takes the entire details of a certain room, including description, items and directions.
* @param currentRoom - The room that is being traversed
*/
public static void roomDetails(Room currentRoom) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method names should start with a verb

*/
public class UserMoves {
/**
* This method takes the entire details of a certain room, including description, items and directions.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description doesn't really tell me what the method does

System.out.println("Here are the items in this room: " + Arrays.toString(currentRoom.getItems()));
ArrayList<String> allPossibleDirections = new ArrayList<>();
DirectionsOnMap[] directions = currentRoom.getDirections();
for(DirectionsOnMap directionName: directions) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling this variable name directionName is a bit of a misnomer because it is a direction object, not a direction name. This also results in the line directionName.getDirectionName() which is needlessly confusing.

System.out.println("Here are the items in this room: " + Arrays.toString(currentRoom.getItems()));
ArrayList<String> allPossibleDirections = new ArrayList<>();
DirectionsOnMap[] directions = currentRoom.getDirections();
for(DirectionsOnMap directionName: directions) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a space before the (

ArrayList<String> allPossibleDirections = new ArrayList<>();
DirectionsOnMap[] directions = currentRoom.getDirections();
for(DirectionsOnMap directionName: directions) {
//Stores all of the possible direction names one can travel in using a String ArrayList

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to say the data structure that is storing the data, it is obvious to the reader from the type specification

System.out.println("Thank you for playing! Goodbye");
System.exit(0);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have vertical whitespace between functions!

}

/**
* This method decides whether a room is at the start or end of the adventure, and prints out statements

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"prints out statements" is really vague and would not help a user understand what this method does

* @param startingRoom - the starting room of the adventure
* @param endingRoom - the ending room of the adventure
*/
public static void beginningOrEnd(Room currentRoom, String startingRoom, String endingRoom) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand the purpose of this function, since you only call it when you know the game started or ended, so why not just print the proper statement then?

}
}
//Returns out the current state of the room if it cannot find a match
System.out.println("I cannot understand " + newDirection);
Copy link

@AkaashKolachina AkaashKolachina Feb 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is relatively minor but the proper message should be "I can't go "direction"!"

}

/**
* This method takes an item, stores it into a list of String variables, and removes it from the overall

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This javadoc is very operational

* @param itemList - the user list of the items
*/
public static void takeItem(Room currentRoom, String pickedItem, ArrayList<String> itemList) {
if(pickedItem == null) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a space before (

for(String item : currentRoom.getItems()) {
//Loops through the current item state to find a match
if (item.equalsIgnoreCase(pickedItem.trim())) {
//Adds the item to the user list of items

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love that you are adding more in-line comments, but don't be redundant with it. You don't need a comment explaining each line. It's obvious you're adding and removing items from your lists

if(pickedItem == null) {
System.out.println("This is a null input");
}
ArrayList<String> fullItemList = new ArrayList<>();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you have this variable since you already have a list of all the items in the room

//Adds the item to the user list of items
itemList.add(pickedItem);
//removes the item room
fullItemList.remove(pickedItem);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you keep switching between Arrays and ArrayLists, it seems really random and is making your code hard to follow.

@@ -0,0 +1,162 @@
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha this is a really cool game idea!

while (!(currentRoom.getName().equals(endingRoom))) {
String input = scanner.nextLine();
input = input.toLowerCase();
if (input.contains("go")) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue with checking like this is that it's not enough for go to be in the input, it needs to be in the front. Also there needs to be two words in a go command: go and the direction. The way you implemented the go check, it would pass even if there's only one word (like golf) which is incorrect behavior.

* Main class that uses a scanner input to call methods, and is used as a UI. Commands include "go", "take",
* "drop", "examine", and more. Accounts for spelling and spacing errors.
*/
public class Main {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your main has way too much in it right now. All of your game logic should be in its own class. At the moment its impossible to test your game engine, which is a big issue as we always want to make our code as easy to test as possible.

currentDesign = mapper.readValue(file, AdventureDesign.class);
} catch (Exception e) {
System.out.println("Please try again!");
System.exit(0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd strongly advise you to stay away from System.exit(). This function kills your entire jvm, which makes your program very inflexible and also a little dangerous.

* This class works much like a linked list, where the Direction acts as a key, and the next room is viewed
* as a value
*/
public class DirectionsOnMap {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just call this class Directions? DirectionsOnMap feels a bit redundant.

//the direction one is going in
private String directionName;
//the next room one will go in following the currentDirection
private String room;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd advise you to call this member variable roomName since you have an object type called Room.

Room currentRoom = rooms[0]; //Walter White Residence
UserMoves.takeItem(currentRoom, "money", userTest);
UserMoves.takeItem(currentRoom, "hat", userTest);
assertEquals(2, userTest.size());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't convince me take works properly. I know 2 items are added to the player list, but I don't know if they are the correct items.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also should verify that the item has been removed from the room

* @param pickedItem - the item that is being taken
* @param itemList - the user list of the items
*/
public static void takeItem(Room currentRoom, String pickedItem, ArrayList<String> itemList) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't modify your parameters in your functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants