(a) Write a class named Pizza based on the following members: ● ● ● A private instance variable name (String) that stores the name of a pizza A private instance variable description (String) that stores the description of a pizza A private instance variable size (char) that stores the size of a pizza. A private class variable discount (float) that stores the discount (in %) of all pizza A parameterized constructor that initialization the attributes name, description and size. A setter for attribute discount A method named price that returns the price of a pizza based on its size: Size 'P' 'R' 'L' Description Personal Regular Large Name Blazing Seafood Chicken Pepperoni Deluxe Cheese Price (RM) 9.90 (b) Based on the class designed in 5(a), write a statement for the following: i) To set the discount to 15%. ii) To create an array of Pizza with 3 elements. Assign the following data to each element: 25.90 37.90 Description Spicy sweet sour sauce, tuna, crabsticks, pineapples Tomato sauce, chicken pepperoni, mozzarella cheese Tomato sauce, mozzarella cheese Size L P
(a) Write a class named Pizza based on the following members: ● ● ● A private instance variable name (String) that stores the name of a pizza A private instance variable description (String) that stores the description of a pizza A private instance variable size (char) that stores the size of a pizza. A private class variable discount (float) that stores the discount (in %) of all pizza A parameterized constructor that initialization the attributes name, description and size. A setter for attribute discount A method named price that returns the price of a pizza based on its size: Size 'P' 'R' 'L' Description Personal Regular Large Name Blazing Seafood Chicken Pepperoni Deluxe Cheese Price (RM) 9.90 (b) Based on the class designed in 5(a), write a statement for the following: i) To set the discount to 15%. ii) To create an array of Pizza with 3 elements. Assign the following data to each element: 25.90 37.90 Description Spicy sweet sour sauce, tuna, crabsticks, pineapples Tomato sauce, chicken pepperoni, mozzarella cheese Tomato sauce, mozzarella cheese Size L P
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 7PE
Related questions
Question
java code, pls use more // comments
![Question 5
(a) Write a class named Pizza based on the following members:
A private instance variable name (String) that stores the name of a pizza
A private instance variable description (String) that stores the description of
a pizza
A private instance variable size (char) that stores the size of a pizza.
A private class variable discount (float) that stores the discount (in %) of all
pizza
A parameterized constructor that initialization the attributes name, description
and size.
A setter for attribute discount
A method named price that returns the price of a pizza based on its size:
Size
'P'
'R'
'L'
Description
Personal
Regular
Large
Name
Blazing Seafood
Chicken Pepperoni
Deluxe Cheese
Price (RM)
9.90
(b) Based on the class designed in 5(a), write a statement for the following:
i) To set the discount to 15%.
ii) To create an array of Pizza with 3 elements. Assign the following data to each
element:
25.90
37.90
Description
Spicy sweet sour sauce, tuna, crabsticks,
pineapples
Tomato sauce, chicken pepperoni, mozzarella
cheese
Tomato sauce, mozzarella cheese
Size
L
R
P](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb1ddeca0-db0c-4fb2-a11d-d0dc67b17cbe%2F4f18acd0-b1c7-462d-9466-ee69335d6dd0%2Fbep0ag8_processed.png&w=3840&q=75)
Transcribed Image Text:Question 5
(a) Write a class named Pizza based on the following members:
A private instance variable name (String) that stores the name of a pizza
A private instance variable description (String) that stores the description of
a pizza
A private instance variable size (char) that stores the size of a pizza.
A private class variable discount (float) that stores the discount (in %) of all
pizza
A parameterized constructor that initialization the attributes name, description
and size.
A setter for attribute discount
A method named price that returns the price of a pizza based on its size:
Size
'P'
'R'
'L'
Description
Personal
Regular
Large
Name
Blazing Seafood
Chicken Pepperoni
Deluxe Cheese
Price (RM)
9.90
(b) Based on the class designed in 5(a), write a statement for the following:
i) To set the discount to 15%.
ii) To create an array of Pizza with 3 elements. Assign the following data to each
element:
25.90
37.90
Description
Spicy sweet sour sauce, tuna, crabsticks,
pineapples
Tomato sauce, chicken pepperoni, mozzarella
cheese
Tomato sauce, mozzarella cheese
Size
L
R
P
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT