Course Answers

BUSINESS
COMPUTER SCIENCE
OTHER COURSES
My Profile

Solved: Finish The Implementation Of The PizzaOrder Class Started At PizzaOrder.java. Look For Methods Mentioning "stub"s. Run PizzaOrder's Main To Test Your Code. Public Class PizzaOrder { Private Pi

By |

Finish the implementation of the PizzaOrder class started at PizzaOrder.java. Look for methods mentioning "stub"s.

Run PizzaOrder's main to test your code.

public class PizzaOrder {
        private Pizza pizza1;
        private Pizza pizza2;
        private Pizza pizza3;
        
        public Pizza getPizza1() { // Need not be leak-safe
                return pizza1;
        }

        public void setPizza1(Pizza pizza1) { 
                this.pizza1 = pizza1;
        }

        public Pizza getPizza2() { // Need not be leak-safe
                return pizza2;
        }

        public void setPizza2(Pizza pizza2) {
                this.pizza2 = pizza2;
        }

        public Pizza getPizza3() { // Need not be leak-safe
                return pizza3;
        }

        public void setPizza3(Pizza pizza3) {
                this.pizza3 = pizza3;
        }

        public int numPizzas() {  // Return the number of pizzas in the order, which is the 
                // number of non-null values in pizza1, pizza2 and pizza3
                System.out.println("numPizzas is still just a stub");
                return 0;  // You need to replace this with an actual calculation
        }

        public PizzaOrder (Pizza p1, Pizza p2, Pizza p3){
                System.out.println("PizzaOrder's 3-argument constructor is still just a stub");
        }
        
        public PizzaOrder (PizzaOrder orig){
                System.out.println("PizzaOrder copy constructor is still just a stub");
        }

        public PizzaOrder (){
                System.out.println("PizzaOrder no-argument constructor is still just a stub");
        }
        
        public String toString() {
                return "PizzaOrder.toString is still just a stub";
        }
        
        public double calcTotal() {
                System.out.println("PizzaOrder.calcTotal() is still just a stub");
                return 0.0; // YOu need to replace this with the actual calculation
        }
        
        public static void main(String[] args) {
                System.out.println("This is a test driver for PizzaOrder.");
                Pizza p1 = new Pizza("small", 1,1,1);
                Pizza p2 = new Pizza("large", 2,0,1);
                PizzaOrder po1 = new PizzaOrder(p1, p2, null);
                System.out.println("Value of order "+po1+" is "+po1.calcTotal()+" and should be 36");
                PizzaOrder copied = new PizzaOrder(po1);
                System.out.println("Value of copied order "+copied+" is "+copied.calcTotal()+" and should also be 36");
                
        }

}


Answer Preview

Note: ########### Pizza.java class is not given in the question. So a class is defined to make the program working. Please chnage the logic of amount calculation accordingly to your need or comment be

Get Answer Now


Buy (USD $9.00)

Get Answer Now

Answered
Buy @ USD $9.00
Related Questions

OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES