1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Greeley [361]
3 years ago
12

Create a class Cola Vending Machine. This class is simulating a cola vending machine. It keeps track of how many cola bottles ar

e in the class and how much one bottle costs. There should be a method sell Bottle which sells one bottle to a customer, decreases the amount of bottles left. There also is a method restock which sets the number of bottles to the number it is restocked to. Write a main method to test the functionality of the Cola Vending Machine machine.
Computers and Technology
1 answer:
vodka [1.7K]3 years ago
5 0

Answer:

public class CocaColaVending {

   private int numBottles;

   private double costPerBottle;

   public CocaColaVending(int numBottles, double costPerBottle) {

       this.numBottles = numBottles;

       this.costPerBottle = costPerBottle;

   }

   public int getNumBottles() {

       return numBottles;

   }

   public void setNumBottles(int numBottles) {

       this.numBottles = numBottles;

   }

   public double getCostPerBottle() {

       return costPerBottle;

   }

   public void setCostPerBottle(double costPerBottle) {

       this.costPerBottle = costPerBottle;

   }

   public void sellBottles(int numSold){

       int remainingStock = this.numBottles-numSold;

       setNumBottles(remainingStock);

   }

   public void restockBottles(int numRestock){

       int newStock = this.numBottles+numRestock;

       setNumBottles(newStock);

   }

}

THE TEST CLASS IS showing the functionality of the class is given in the explanation section

Explanation:

public class CocaColaVendingTest {

   public static void main(String[] args) {

       CocaColaVending vending = new CocaColaVending(1000,2.3);

              System.out.println("Intial Stock "+ vending.getNumBottles());

       vending.sellBottles(240);

       System.out.println("After Selling 240 bottles "+ vending.getNumBottles());

       vending.restockBottles(1000);

       System.out.println("After restocking 1000 bottles "+ vending.getNumBottles());

   }

}

You might be interested in
Allison’s computer is displaying a strange error message saying that Allison, who is an administrator, does not have access to a
Margaret [11]

Answer:

restart computer,check to see who was last on her account or call a technician  

Explanation:

8 0
3 years ago
Which of the following is considered both an input and output peripheral? Keyboard, Microphone, Speaker, Touchscreen monitor
Aleks04 [339]
Touchscreen monitor.
6 0
3 years ago
Read 2 more answers
What block(s) would most effectively keep a sprite from moving off the screen?
Sonja [21]

The block most effectively keep a sprite from moving off the screen if if on edge, bounce. Hence option B is correct.

<h3>What is screen?</h3>

Screen is defined as a portable or stationary object that offers shelter, acts as a partition, etc., and often consists of a covered frame. Screening is defined as the procedure of locating or choosing individuals from a community according to one or more selection criteria.

The block will kept more perfectly if one of the edge there is bounce so that the box will not fall from the sprite.

Thus, the block most effectively keep a sprite from moving off the screen if if on edge, bounce. Hence option B is correct.

To learn more about screen, refer to the link below:

brainly.com/question/23902291

#SPJ1

8 0
1 year ago
What technology has a function of using trusted third-party protocols to issue credentials that are accepted as an authoritative
jarptica [38.1K]

Answer: PKI certificates

Explanation: PKI is known as the public key infrastructure which is commonly used for the encryption of the data and also for the data signing. They have the ability to assign the keys pair.

PKI certificates are in the form of strings of alpha-numeric running for a mathematical functions. They use the third party protocols for the execution and they are widely accepted by the authoritative identity.

5 0
2 years ago
While the Internet can be a great resource, the information is not always reliable, as anyone can post information. Select one:
Olin [163]

Answer: True

Explanation: Because anyone can post something and it can be non reliable

7 0
3 years ago
Other questions:
  • in what way do rules and laws created to address public problems affect individuals groups and business
    13·1 answer
  • Type the correct answer in the box spell all words correctly
    8·1 answer
  • Name the function in Python that prompts user to enter values as per the data type specified.
    5·1 answer
  • Select the correct answer.
    13·1 answer
  • Which of the following is not true about search engine advertising?
    15·1 answer
  • What are two examples of management information systems?
    12·1 answer
  • What term is used to refer to the way companies collect and process data in order to create new information to make important bu
    13·1 answer
  • Write a function safeOpen() that takes one parameter, filename — a string giving the pathname of the file to be opened for readi
    15·1 answer
  • What is the primary responsibility of the federal reserve bank??
    11·1 answer
  • Is there any difference beetween the old version of spyro released on the origional and the newer ones??? or is it only change i
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!