Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Code for the DonutOrder class is given below. Complete the following: (a) Add a private static integer called numOders and give it a default

1. Code for the DonutOrder class is given below. Complete the following:

  • (a) Add a private static integer called numOders and give it a default value of zero
  • (b) Add a public static method called getNumOrders() that will return the content numOrders static variable
  • Modify the DonutOrder constructors that takes value so that it modifies numOrders appropriately

public class DonutOrder{

private int number;

private double price;

// part (a) include the static variable below

//part (c) modify both constructors to update numOrders

public DonutOrder()

{

number = 1;

price = 0.99;

}

public DonutOrder(int amount, double cost)

{

number = amount;

price = cost;

}

public int getNumber()

{return number;}

public double getPrice()

{return price;}

public void setNumber(int num)

{number = num;}

public void setPrice(double cost)

{price = cost;}

public String toString()

{return "The donut order has " + number + "donut(s) for the price of $"+ price;}

// part (b) include the static method below

}

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

Step: 3

blur-text-image

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

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

What is liability of newness?

Answered: 1 week ago