subject

Need this java code its on zybooks. Given two integers as user inputs that represent the number of drinks to buy and the number of bottles to restock, create a VendingMachine object that performs the following operations: Purchases input number of drinks

Restocks input number of bottles

Reports inventory

The vending machine is found in VendingMachine. java. A VendingMachine's initial inventory is 20 drinks.

Ex: If the input is:

5 2

the output is:

Inventory: 17 bottles.

The file that comes with it:

// simulates a simple vending machine with operations to purchase drinks and check inventory.

public class VendingMachine {

// number of bottle in stock

private int bottles;

// initial inventory is 20

public VendingMachine(){

bottles = 20;

}

public void purchase(int amount){

bottles = bottles - amount;

}

public int getInventory(){

return bottles;

}

public void restock(int amount){

bottles = bottles + amount;

}

public void report(){

System. out. println("Inventory: " + bottles + " bottles");

}

}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:50
Explain why it is reasonable to assume that receiving 3 duplicate acks in tcp is an indication that the network is not currently congested.
Answers: 1
question
Computers and Technology, 22.06.2019 15:10
Consider a direct-mapped cache with 216 words in main memory. the cache has 16 blocks of 8 words each. it is a word-addressable computer (rather than a byte-addressable computer which we normally discuss). (a) how many blocks of main memory are there? (b) what is the format of a memory address as seen by the cache, that is, what are the sizes of the tag, cache block, and block offset fields (if they apply)? (c) to which cache block will the memory reference db6316 map?
Answers: 1
question
Computers and Technology, 23.06.2019 02:30
Experimental data that is expressed using numbers is said to be
Answers: 1
question
Computers and Technology, 23.06.2019 16:00
Helen is having a meeting with her colleagues in her company. they are working on the goals and objectives for the coming year. they want to ensure that these goals and objectives of the processes involved are properly evaluated. which system can helen and her colleagues apply to evaluate this? helen and her colleagues require a blank to evaluate the goals and objectives.
Answers: 2
You know the right answer?
Need this java code its on zybooks. Given two integers as user inputs that represent the number of d...
Questions
question
Mathematics, 15.12.2020 21:40
question
Mathematics, 15.12.2020 21:40
question
Mathematics, 15.12.2020 21:40
question
Mathematics, 15.12.2020 21:40
question
English, 15.12.2020 21:40
question
Mathematics, 15.12.2020 21:40
question
Computers and Technology, 15.12.2020 21:40