Question: import java.util.ArrayList; class Main { public static void main(String[] args) { ArrayList toys = new ArrayList (); toys.add(new Toy(Lego Set, 29.99)); toys.add(new Toy(Monopoly Deal, 17.50));

import java.util.ArrayList;

class Main {

public static void main(String[] args) {

ArrayList toys = new ArrayList();

toys.add(new Toy("Lego Set", 29.99));

toys.add(new Toy("Monopoly Deal", 17.50));

toys.add(new Toy("Rubik's Cube", 10.00));

toys.add(new Toy("Nerf Gun", 39.99));

toys.add(new Toy("Barbie Doll", 12.99));

toys.add(new Toy("basketball", 19.99));

toys.add(new Toy("scooter", 59.99));

ToyBox toyBox = new ToyBox(4,3,toys);

System.out.println(" *** Toy Box Check ***");

System.out.println(toyBox);

Toy elCheapo = toyBox.cheapestToy();

System.out.println("Cheapest Toy: " + elCheapo);

System.out.println(" *** Game Show Board Check ***");

String[] clues = new String[30];

for(int i = 0; i < 30; i++)

clues[i] = "a";

GameShowBoard b = new GameShowBoard(5,6,clues);

b.chooseBonus();

System.out.println(b);

}

} ------------------------------------------------

class Clue {

private int dollarAmount;

private String clue;

private boolean isBonus;

public Clue(int d, String c)

{

dollarAmount = d;

clue = c;

isBonus = false;

}

public void setBonus()

{

isBonus = true;

}

//not shown on quiz

public boolean isBonus()

{

return isBonus;

}

public String toString()

{

return "[$" + dollarAmount + "]";

}

}

---------------------------------------------------------

class GameShowBoard {

private Clue[][] board;

public GameShowBoard(int rows, int cols, String[] clues)

{

board = new Clue[rows][cols];

int i = 0;

int dollars = 100;

for(int r = 0; r

{

for(int c=0; c

{

board[r][c] = new Clue[i];

dollar += 100;

}

}

}

public void chooseBonus()

{

/* PART B - Randomly chooses any one any

one of the Clues in board and sets its

isBonus state to true */

}

-----------------------------------------------

class Toy {

private String name;

private double cost;

public Toy(String n, double c)

{

name = n;

cost = c;

}

public double getCost()

{

return cost;

}

public String getName()

{

return name;

}

//not shown on quiz

public String toString()

{

String s = name + " $" + cost;

while (s.length() < 20)

s += " ";

return s;

}

}

-------------------------------------------------------

import java.util.ArrayList;

class ToyBox {

private Toy[][] box;

public ToyBox(int rows, int cols, ArrayList toys)

{

/*Part A - initializes box to have dimensions rows

by cols. Toys in the toys arraylist are copied into

the 2D array box in row major order. Empty

spaces in the box are assigned null.

Given: rows * cols >= toys.size() */

}

public Toy cheapestToy()

{

/*Part B - returns the cheapest Toy in box.

In case of a tie, return either Toy. You can assume

there is at least one Toy in the box and that there

is a Toy (not null) at position row 0, column 0 */

return null;

}

public String toString()

{

String build = "";

for(Toy[] row: box)

{

for(Toy t : row)

{

if(t != null)

build += t;

else

build += "Empty Space ";

}

build += " ";

}

return build;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!