Question

Create a main method inside the ShoppingCart - create a vegetable object - call the addprice...

Create a main method inside the ShoppingCart 

   - create a vegetable object
       - call the addprice method polymorphically
       - call the display method polymorphically

   - create a meat object
      - call the addprice method polymorphically
      - call the display method polymorphically

Homework Answers

Answer #1

I am solving the question in Java as the question has not specified the language to solve the problem.I am assuming the Shopping cart is a class and vegetable and meat are child classes of shopping cart. Please find the attached COMMENTS in the answer for better understanding. THANK YOU.

public static void main(String args[] ) {

/* FOR THE VEGETABLE SECTION */

ShoppingCart veg_obj= new Vegetable();   //creating the vegtable object 

veg_obj.addprice();     //calling addprice() method  polymorphically 
veg_obj.display();     // callind the display method polymorphically 

/*FOR MEAT SECTION */

ShoppingCart meat_obj= new meat();            //creating the meat object 

meat_obj.addprice();      //calling the addprice method polymorphically 

meat_obj.display();     // calling the display method polymorphically 

}
 
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
java coding Create two objects S1 and S2 that uses the default constructor · Call the...
java coding Create two objects S1 and S2 that uses the default constructor · Call the ‘display’ method for objects S1 and S2. · Call the ‘setGrade’method that increments the grade by 1 for object S2 · Call the ‘getGrade’ method that will display the value variable grade for objects S1 and S2
In C++ Create a method that populates an array: pArray(), be sure to have the appropriate...
In C++ Create a method that populates an array: pArray(), be sure to have the appropriate return type, and parameters. Call pArray() in your main() method.
Write the following problem in Java Create a class Dog, add name, breed, age, color as...
Write the following problem in Java Create a class Dog, add name, breed, age, color as the attributes. You need to choose the right types for those attributes. Create a constructor that requires no arguments. In this constructor, initialize name, breed, age, and color as you wish. Define a getter and a setter for each attribute. Define a method toString to return a String type, the returned string should have this information: “Hi, my name is Lucky. I am a...
how to increase and create the public awareness about using vegetable oils and cardiovascular diseases?
how to increase and create the public awareness about using vegetable oils and cardiovascular diseases?
Find the error in the following pseudocode. Module main()     Declare Real mileage     Call getMileage()...
Find the error in the following pseudocode. Module main()     Declare Real mileage     Call getMileage()     Display "You've driven a total of ", mileage, " miles." End Module Module getMileage()     Display "Enter your vehicle’s mileage."     Input mileage End Module
I would like to create a rectangular vegetable patch. The fencing for the east and west...
I would like to create a rectangular vegetable patch. The fencing for the east and west sides costs $4 per foot, and the fencing for the north and south sides costs only $2 per foot. I have a budget of $128 for the project. What are the dimensions of the vegetable patch with the largest area I can enclose? north and south sides= ? east and west sides = ?
For tax reasons, I need to create a rectangular vegetable patch with an area of exactly...
For tax reasons, I need to create a rectangular vegetable patch with an area of exactly 200 square feet. The fencing for the east and west sides costs $4 per foot, and the fencing for the north and south sides costs only $2 per foot. What are the dimensions of the vegetable patch with the least expensive fence? north and south sides fteast and west sides ft
I would like to create a rectangular vegetable patch. The fencing for the east and west...
I would like to create a rectangular vegetable patch. The fencing for the east and west sides costs $4 per foot, and the fencing for the north and south sides costs only $2 per foot. I have a budget of $176 for the project. What are the dimensions of the vegetable patch with the largest area I can enclose? HINT [See Example 2.]. North East sides = East and West sides =
Create and use an enumeration create an enumeration and use it in a test application. 1....
Create and use an enumeration create an enumeration and use it in a test application. 1. Import the project named ch13 ex 2 Enumeration that's in the ex starts folder, 2. Create an enumeration named CustomerType. This enumeration should contain constants that represent three types of customers: retail. trade, and college. Use an enumeration 3. open the Customer Type App class. Then, add a method to this class that returns a discount percent C10 for retail. 30 for trade. and.20...
Java Code import java.util.Scanner; /** Create two methods as instructed below and then call them appropriately....
Java Code import java.util.Scanner; /** Create two methods as instructed below and then call them appropriately. Hint: Only one of the methods you create needs to be called from the main method. */ public class LandCalculation { public static void main(String[] args) { final int FEET_PER_ACRE = 43560; // Number of feet per acre double tract = 0.0, acres = 0.0; Scanner keyboard = new Scanner(System.in); System.out.print("Enter the tract size: "); tract = keyboard.nextDouble(); // Validate the user's input. while(tract...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT