Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java homework

nenl12
nenl12 


Hello! I have attached my assignment and the files that I have so far. According to the TA at school, the files that I already have a class file for are good to go, but I'm not sure if that's true. I'm confused by the instructions provided and I'm stuck. Please help. My assignment is due by 6am. Attachments Tags Clarifications

Answers

Solution - Fruit Game

mariobeka
mariobeka 



Below you will find the code solution. I reformat the code and made comments to proper understand what i was doing and also following the specifications of your assignment. Attachments
Lab6-Assignment.zip (3 K) Download
Preview
public FoodGame(int num) { theSpinner = new Spinner(); players = new ArrayList<Player>(num); // Add the players in the array list for (int i = 0; i < num; i++) { players.add(new Player("Player " + (i + 1))); } }

Preview
many players? "); number = input.nextInt(); FoodGame game = new FoodGame(number);

Preview
private String name; // Constructor public FoodItem(String nm) { name = nm; } // Getter and setter

Preview
Fruit(String nm) { super(nm); } /** * Get the value

Preview
Score is " + "now " + getScore() + "\n"); } // Getter and Setter methods. public int getScore() { return score; } public String getName() { return name; } public void setName(String name) {

Preview
foods = new ArrayList<FoodItem>(7); // Add 3 vegetables, 4 fruits and 1 sweet in the arraylist. foods.add(new Fruit("Apple")); foods.add(new Vegetable("Lettuce")); foods.add(new Fruit("Strawberry")); foods.add(new Sweet("Donut")); foods.add(new Vegetable("Cucumber")); foods.add(new

Preview
* @return the value of this sweet. */ public int getValue() {

Preview
Get the value of this vegetable. * * @return the value of this

Screen Shot 2015-04-04 at 7.10.20 AM.png (162 K) Download Preview

Screenshots
Screenshot
Purchase Answer

Re-written complete programs with proper instructions

OutOfBounds
OutOfBounds 



complete solution with all classes implementation with
--proper format
--proper comments
--no missing attribute
--no missing loop
Attachments
Lab6-YourName.zip (7 K) Download








Preview
= players.get(i); System.out.println("Starting "+player.name+"'s turn with score = "+player.getScore()); /* * Player taking turn */ player.takeTurn(spinner); /* * Checking players win */ if(player.getScore()>=50){ System.out.println(player.name+" won

Preview
Scanner scanner = new Scanner(System.in); System.out.print("Enter number of players:"); int numberOfPlayers

Preview
} public void setName(String name) { this.name = name; } @Override public String toString()

Preview
public Fruit(String name) { super(name); }

Preview
spingame; public class Player { String name; int score; Player(String name){ this.name = name; score = 0;

Preview
Vegitable("Spinach")); foods.add(new Fruit("Apple")); foods.add(new Sweet("Donut")); foods.add(new Vegitable("Broccoli")); foods.add(new Fruit("Pear")); } FoodItem spin(){ /* * Generating random number to select food item */ Random randomGenerator = new Random(); randomMaker = randomGenerator.nextInt(8);

Preview
Sweet(String name) { super(name); }

Preview
{ public Vegitable(String name) {

Screen Shot 2015-04-04 at 12.12.46 PM.png (202 K) Download Preview

Screen Shot 2015-04-04 at 12.13.05 PM.png (135 K) Download Preview

Screenshots
Screenshot
Screenshot
Purchase Answer