Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

So I have to create this java game for class. How it\'s marked is that we upload

ID: 3534001 • Letter: S

Question

So I have to create this java game for class. How it's marked is that we upload the code to a uni website and they provide a mark and differences in output to show you where the problems are in the code. If someone can show me why I'm getting false instead of true, and how to correct it, I'll give you the full points .

The task I'm up to:


My output vs. what the output should be:



My code:
import java.util.*;


public class Global

{

public static final Scanner keyboard = new Scanner(System.in);

}


public class Ground

{

private Jar jar1, jar2, jar3;

private Player player;

private Chest chest;


Ground()

{

player = new Player();

jar1 = new Jar(1, new Stone());

jar2 = new Jar(2, new Stone());

jar3 = new Jar(3, new Stone());

chest = new Chest();

}


public boolean isChestUnlocked()

{

int a=chest.jar1.getStoneWeight();

int b=chest.jar2.getStoneWeight();

int c=chest.jar3.getStoneWeight();

int d=chest.getCombination();

if((a+(b*c)==d))

{

return true;

}

else

{

return false;

}

}

}


public class Player

{

private String name;

private int position;

private Jar jar;


Player()

{

position = 0;

jar = new Jar();

System.out.print("Enter player's name: ");

name = Global.keyboard.nextLine();

}


public void move(int distance)

{

position = position+distance;

jar.move(distance);


}


public void pickUp(Jar jar)

{

jar.moveTo(this.jar);

}

}


public class Jar

{

private int position;

private Stone stone;


Jar()

{

position = 0;

stone = null;

}


public Jar(int position, Stone stone)

{

this.position = position;

this.stone = stone;

}

  

public int getStoneWeight()

{

return stone.getWeight();

  

}


public void move(int distance)

{

position = position+distance;

}


public void moveTo(Jar jar)

{

jar.stone = stone;

stone = null;

}


}


public class Stone

{

private String name;

private static int weight;


Stone()

{

System.out.print("Enter stone name: ");

name = Global.keyboard.nextLine();

System.out.print("Enter stone weight: ");

weight = Global.keyboard.nextInt();

Global.keyboard.nextLine();

}

  

public static int getWeight()

{

return weight;

}


}

Explanation / Answer

I can do this. You can contact me on timacs12@gmail.com

You can give points after i give u answer

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote