Concept explainers
Pure Abstract Base Class Project
Define a pure abstract base class called BasicShape. The BasicShape class should have the following members:
Private Member Variable:
area: A double used to hold the shape’s area.
Public Member Functions:
get Area: This function should return the value in the member variable area.
calcArea: This function should be a pure virtual function.
Next, define a class named Circle. It should be derived from the BasicShape class. It should have the following members:
Private Member Variables:
centerX: a long integer used to hold the x coordinate of the circle’s center
centerY: a long integer used to hold the y coordinate of the circle’s center radius: a double used to hold the circle’s radius Public Member Functions:
constructor: accepts values for centerX. centerY, and radius. Should call the overridden calcArea function described below.
getCenterX: returns the value in centerX
getCenterY: returns the value in centerY
calcArea: calculates the area of the circle (area = 3.14159 * radius * radius) and stores the result in the inherited member area.
Next, define a class named Rectangle. It should be derived from the BasicShape class. It should have the following members:
Private Member Variables:
width: a long integer used to hold the width of the rectangle
length: a long integer used to hold the length of the rectangle
Public Member Functions:
constructor: accepts values for width and length. Should call the overridden
calcArea function described below.
getWidth: returns the value in width.
get Length: returns the value in length.
calcArea: calculates the area of the rectangle (area = length * width) and stores the result in the inherited member area.
After you have created these classes, create a driver
Trending nowThis is a popular solution!
Chapter 15 Solutions
Starting Out with C++ from Control Structures to Objects, Student Value Edition (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Programming Logic and Design (4th Edition)
Database Concepts (8th Edition)
Starting Out with Python (4th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
- There are two types of data members in a class: static and non-static. Provide an example of when it might be useful to have a static data member in the actual world.arrow_forwardemployee and production worker classes write an employee class that keeps data attributes for the following pieces of information: • employee name • employee number next, write a class named productionworker that is a subclass of the employee class. the productionworker class should keep data attributes for the following information: • shift number (an integer, such as 1, 2, or 3) • hourly pay rate the workday is divided into two shifts: day and night. the shift attribute will hold an integer value representing the shift that the employee works. the day shift is shift 1 and the night shift is shift 2. write the appropriate accessor and mutator methods for each class. once you have written the classes, write a program that creates an object of the productionworker class and prompts the user to enter data for each of the object’s data attributes. store the data in the object, then use the object’s accessor methods to retrieve it and display it on the screen. satak overfallowarrow_forwardDesign an Employee class that has fields for the following pieces of information:• Employee name• Employee numberNext, design a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information:• Shift number• Hourly pay rateThe workday is divided into shifts: day and night. The shift field will hold an int value representing shift that the employee works. The day sifts is shift 1 and the night shift is shift 2. Design the appropriate accessor and mutator methods for each class.Once you have designed the classes, design a program that creates an object of the ProductionWorker class and prompts the user to enter data for each of the object’s fields. Store the data in the object and then use the object’s accessor methods to retrieve it and display it on the screen.Program Sample Run #1The worker name is John RobinsThe worker number is 1234The shift is 1The rate is 36.0arrow_forward
- Movie Information Write a class named MovieInfo that holds data about movie. The class should have the following member variables: title: hold movie’s name category: hold movie’s category year: hold released year mins: hold running time in mins. Write a constructor that accepts arguments for each member variable, appropriate mutator functions that store values in these member variables, and accessor functions that return the values in theses member variables. Once you have written the class, write a separate program that creates four MovieInfo objects and stores the following data in them. Here is the information of four MovieInfo objects: moive1, moive2, moive3, moive4 movie1 title The Book of Life category Animation |Adventure | Comedy year 2014 mins 95 moive2 title Roman Holiday category Comedy | Drama | Romance year 1953 mins 118 movie3 title Kung Fu Panda category Animation | Action…arrow_forwardNewspaperSubscriber class- create an abstract class named NewspaperSubscriber with attributes to contain the subscriber’s street address and the subscription rate. Include get and set methods for both these attributes. The set method for the rate is abstract. The setAddress method must prompt the user to enter the subscriber’s address through the use of a dialog box. Create a constructor for the base class. Create a toString() method that concaternates and returns the subscriber’s street address and rate for display. Create 3 child classes named SevenDaySubscriber, Weekday Subscriber, and Weekend Subscriber. Each child class has an additional attribute called subType, which is a String, that will store the type of newspaper subscription. Create a setType method that will set the type of subscriber as follows: “Seven Day”, “Weekday”, or“Weekend”. Create a setRate method for each child class that sets the rate as follows: a SevenDaysubscriber pays R18.00 per week for his newspapers, a…arrow_forwardThere are two types of data members in a class: static and non-static. Give an example of real-world use for a static data member.arrow_forward
- ShiftSupervisor Class In a particular factory, a shift supervisor is a salaried employee who supervises a shift. In addition to a salary, the shift supervisor earns a yearly bonus when his or her shift meets production goals. Design a ShiftSupervisor class that extends the Employee class you created in Problem 1, The ShiftSupervisor class should have a field that holds the annual salary and a field that holds the annual production bonus that a shift supervisor has earned. Write one or more constructors and the appropriate accessor and mutator methods for the class. Demonstrate the class by writing a program that uses a ShiftSupervisor object. beginner code because this is an intro to java class.arrow_forwardDefine a class called student that has thefollowing data members: - int student number- string student name- double student averageThe following member functions:- Constructor that initialize the datamembers with default values. - set and getfunctions for each data member- Print function to print the values of data members.arrow_forwardBreed Class Create a Breed class with the following: Member Variables Create the following private member variables, all of type std::string: species_ breed_name_ color_ Constructors Create a default constructor for Breed that sets its species_ to "Dog", breed_name_ to "Pug", and color_ to "Fawn". Create a non-default constructor that receives a std::string for species_, breed_name_, and color_; in that order. The values from the constructor should appropriately assign the member variables. Accessors and Mutators Create accessors and mutators for all member variables, following the naming conventions covered in class. e.g. for species_, name the accessor Species, and the mutator SetSpecies. Pet Class Create a Pet class with the following: Member Variables Create the following private member variables: std::string name_ Breed breed_ double weight_ Constructors Create a default constructor for Pet that sets its name to "Doug" and weight to 15.6. The Breed object will…arrow_forward
- Define a class called graduatestudent that inheritsdata members and functions from the class student,and then declare the following data members :- int level- int yearMember functions:- constructor -set and get functions for each data member- Print function.arrow_forwardPets Breed Class Create a Breed class with the following: Member Variables Create the following private member variables, all of type std::string: species_ breed_name_ color_ Constructors Create a default constructor for Breed that sets its species_ to "Dog", breed_name_ to "Pug", and color_ to "Fawn". Create a non-default constructor that receives a std::string for species_, breed_name_, and color_; in that order. The values from the constructor should appropriately assign the member variables. Accessors and Mutators Create accessors and mutators for all member variables, following the naming conventions covered in class. e.g. for species_, name the accessor Species, and the mutator SetSpecies. Pet Class Create a Pet class with the following: Member Variables Create the following private member variables: std::string name_ Breed breed_ double weight_ Constructors Create a default constructor for Pet that sets its name to "Doug" and weight to 15.6. The Breed object will…arrow_forwardActivity - Abstract Class An English teacher wants to find assessment mark of all the students in his course. Write a java program to find assessment mark of the students using following instructions. Save the project/file as StudentAbstract. A) Abstract Class name: Assessment Abstract Member Method: - to calculate and return total score totalScore() B) Class name: English extends Assessment Member variables: QuizMark, PracticeTest, ListeningMark Member Method : - Constructor to initialize member variables - to calculate and return total score totalScore QuizMark + PracticeTest*0.25 + %3D ListeningMark/2 C) Controlling class : StudentAbstract - To create an object of English class - To print totalScore of the Englisharrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage