Mick’s Wicks makes color straw in various sizes. Create a class for the business named Straw that contains data fields for color, height, and price. Create get methods for all three fields. Create set methods for color and height, but not for price. Instead, when height is set, determine the price as $4 per inch. Create a child class named CurveStraw that contains an additional data field named ShortStraw and methods to get and set it. In the child class, override the parent’s setHeight() method to set the price of a CurveStraw object at $5 per inch. Write an application that instantiates an object of each type and displays thedetails.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Mick’s Wicks makes color straw in various sizes. Create a class for the business named Straw
that contains data fields for color, height, and price. Create get methods for all three fields.
Create set methods for color and height, but not for price. Instead, when height is set,
determine the price as $4 per inch. Create a child class named CurveStraw that contains an
additional data field named ShortStraw and methods to get and set it. In the child class,
override the parent’s setHeight() method to set the price of a CurveStraw object at $5 per
inch. Write an application that instantiates an object of each type and displays thedetails.
Step by step
Solved in 4 steps with 1 images