Question: How can help to create this program? PartBDriver public class PartBDriver { public static void main (String[] args) { // create the first SodaMachine Output.showMessage(Creating

How can help to create this program?

How can help to create this program? PartBDriver public class PartBDriver {public static void main (String[] args) { // create the first SodaMachineOutput.showMessage("Creating default Soda Machine..."); SodaMachine sm1 = new SodaMachine(); Output.showMessage("Machine #1: "

PartBDriver

public class PartBDriver { public static void main (String[] args) { // create the first SodaMachine Output.showMessage("Creating default Soda Machine..."); SodaMachine sm1 = new SodaMachine(); Output.showMessage("Machine #1: " + sm1.toString()); // create the second SodaMachine Output.showMessage("Creating second Soda Machine..."); SodaMachine sm2 = new SodaMachine(1.00, 5); Output.showMessage("Machine #2: " + sm2.toString()); // manipulate the first machine Output.showMessage("Buying a soda from Machine #1..."); sm1.buySoda(); Output.showMessage("Machine #1: " + sm1.toString()); Output.showMessage("Changing price and repeating..."); sm1.setPrice(0.50); sm1.buySoda(); Output.showMessage("Machine #1: " + sm1.toString()); // manipulate the second machine Output.showMessage("Trying to buy 7 sodas from Machine #2..."); int count = 0; while (count sm2.getNumSodas()) Output.showMessage("Machine #1 has more sodas."); else Output.showMessage("Machine #2 has more sodas."); if (sm1.getPrice() == sm2.getPrice()) Output.showMessage("Machines have the same price-per-soda."); else if (sm1.getPrice() > sm2.getPrice()) Output.showMessage("Machine #1 has a higher price-per-soda."); else Output.showMessage("Machine #2 has a higher price-per-soda."); } // method main } // class PartBDriver

Purpose: The main purpose of this lab is to give you experience designing and implementing your own object classes in Java. You will write one object class for each part, and you will use the provided Java applications to test your completed object classes. Each of your object classes must be arranged in the following three sections, each marked with a comment: instance variables, constructor(s), and instance methods. Your toString methods should return a String containing all instance variables in a sentence, with any instance variables representing monetary values formatted as money formatted to two decimal places. Hints/Tips: Though the details of each class are different, the steps to take in writing your object classes are the same steps taken in Lecture 23 to write the LightSwitch class. As usual, it is a good idea to write your class one section or method at a time, testing for compilation after each. You can also write short test applications that test the completed methods before all the methods are written and ready for the final test program

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!