Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

file 6 package asmt01; public class Tester { public static void main(String[] args) { try { // Price for x of BB Bread brownBread =

file 6

package asmt01;

public class Tester {

public static void main(String[] args) {

try {

// Price for x of BB

Bread brownBread = new BrownBread("BB", 5);

System.out.println("BrownBread: $"

+ brownBread.calculateTypePrice());

// Price for x of MB

Bread multiSeeds = new MultiSeedsBread("MB", 10);

System.out.println("MultiSeedsBread: $"

+ multiSeeds.calculateTypePrice());

// Price for x of RB

Bread ryeBread = new RyeBread("RB", 15);

System.out.println("Ryebread: $"

+ ryeBread.calculateTypePrice());

// Total Earnings

double totalEarnings

= ryeBread.calculateTypePrice()

+ brownBread.calculateTypePrice()

+ multiSeeds.calculateTypePrice();

System.out.println("Total earnings: $"

+ totalEarnings);

// Number of loaves for a given bread type and money amount

Person person = new Person("BB", 25);

System.out.println(" You may buy "

+ person.calculatePossibleBreadBought() + " of this"

+ " type of bread.");

} catch (IllegalArgumentException illArgExc) {

System.out.println(illArgExc.getMessage());

}

}

}

file 5

package asmt01;

public class RyeBread extends Bread {

protected static final double PRICE_PER_ITEM = 1.3;

public RyeBread(String name, int amount) {

}

public String getName() {

}

public void setName(String name) {

}

public double calculateTypePrice() {

}

}

file 4

package asmt01;

public class Person {

private String name;

private double money;

public Person(String name, double money) {

}

public String getName() {

}

private void setName(String name) {

}

public double getMoney() {

}

private void setMoney(double money) {

}

public int calculatePossibleBreadBought() {

switch (this.getName()) {

}

return possibleBuyings;

}

}

file 3

package asmt01;

public class MultiSeedsBread extends Bread {

protected static final double PRICE_PER_ITEM = 1.2;

public MultiSeedsBread(String name, int amount) {

}

public String getName() {

}

public void setName(String name) {

}

public double calculateTypePrice() {

}

}

file 2

package asmt01;

public class BrownBread extends Bread {

protected static final double PRICE_PER_ITEM = 1.1;

public BrownBread(String name, int amount) {

}

public String getName() {

}

public void setName(String name) {

}

public double calculateTypePrice() {

}

}

file 1

package asmt01;

public abstract class Bread {

private String name;

private int amount;

public Bread(String name, int amount) {

}

public String getName() {

}

public void setName(String name) {

}

public int getAmount() {

}

private void setAmount(int amount) {

}

public abstract double calculateTypePrice();

}

image text in transcribed

image text in transcribed

A previous programmer left some code (at http: //csc220.ducta.net/Assignments/Assignment-01-Code.zip). Please continue implementing the code to produce the following output: run: BrownBread: $5.5 MultiSeedsBread: $12.0 Ryebread: $19.5 Total earnings: $37.0 You may buy 22 of this type of bread. "TesterAskUser" is an interactive version of "Tester". a. "TesterAskUser" askes users for a type of bread and a number of loaves they want to buy then tell them how much the total is for each type of bread. It also gives the owner the total earnings. b. If a user tells "TesterAskUser" an amount the user wants to spend and the type of bread the user wants to buy, "TesterAskUser" lets the user know how many loaves of that bread type the user may buy. c. You need to handle IllegalArgumentException ()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

LO4 Provide an overview of four challenges facing HR today.

Answered: 1 week ago