C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 20, Problem 20.9E
(Abstract Base Classes) Suggest one or more levels of abstract base classes for the Shape hierarchy discussed in this chapter and shown in Fig19.3. (The first level is Shape, and the second level consists of the classes TwoDimensionalShape and ThreeDimensionalShape.)
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Abstract Base Classes) Suggest one or more levels of abstract base classes for the Shape hierarchy discussed in this chapter and shown in Fig. 19.3. (The first level is Shape, and the secondlevel consists of the classes TwoDimensionalShape and ThreeDimensionalShape.)
This is object oriented programming
Language is C++
Consider the following scenario of a class Person. A Person class has a Name, ID, Address and has functions of change the address and profile display. (Hint: Composition is not applied)
Two classes are derived from this class person. 1) Student 2) Employee.
The student class has a course number, classes attended, year (freshman=1, sophomore=2 and so on), and functions to change course and profile display.
The employee class has a Date of joining and date of promotion.
The employee class further has two child classes 1) Faculty 2) Admin.
Faculty class has a course number, classes taught, Rank (AP, lecturer etc) and a function to display profile.
Admin class has number of projects worked on and a display profile function.
Answer the questions based on this scenario.
Make the classes as mentioned above. Make appropriate constructors and functions. Choose access type wisely.
3. (10) Given below is the CRC diagram for a Circle ADT. Give the class definition and
function definitions for this ADT.
Circle
- int r
// radius
// Constructors
+ Circle( int )
// Mutator
+ void setR( int)
II Accessors
+ int getR( )
+ int area( )
Chapter 20 Solutions
C How to Program (8th Edition)
Ch. 20 - Prob. 20.3ECh. 20 - (Polymorphism vs. switch logic) Discuss the...Ch. 20 - (Inheriting Interface vs. Implementation)...Ch. 20 - Prob. 20.6ECh. 20 - (Dynamic Binding vs. Static Binding) Distinguish...Ch. 20 - Prob. 20.8ECh. 20 - (Abstract Base Classes) Suggest one or more levels...Ch. 20 - Prob. 20.10ECh. 20 - (Polymorphic Application) Youve been asked to...Ch. 20 - (Payroll System Modification) Modify the payroll...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
T F When an array of objects is defined, the constructor is only called for the first element.
Starting Out with C++ from Control Structures to Objects (9th Edition)
The decimal number system is a weighted system with ten digits.
Digital Fundamentals (11th Edition)
Write a program that reads in five amounts of money, doubles each amount, and then writes out the doubled value...
Problem Solving with C++ (10th Edition)
Car Loan If A dollars are borrowed at r interest compounded monthly to purchase a car with monthly payments for...
Introduction To Programming Using Visual Basic (11th Edition)
A(n) _____ is a specialized routine that performs a specific operation and then returns a value.
Starting Out With Visual Basic (7th Edition)
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.Similar questions
- Nutritional information (classes/constructors) PYTHON ONLY Complete the FoodItem class by adding a constructor to initialize a food item. The constructor should initialize the name (a string) to "None" and all other instance attributes to 0.0 by default. If the constructor is called with a food name, grams of fat, grams of carbohydrates, and grams of protein, the constructor should assign each instance attribute with the appropriate parameter value. The given program accepts as input a food item name, fat, carbs, and protein and the number of servings. The program creates a food item using the constructor parameters' default values and a food item using the input values. The program outputs the nutritional information and calories per serving for both food items. Ex: If the input is: M&M's10.034.02.01.0 where M&M's is the food name, 10.0 is the grams of fat, 34.0 is the grams of carbohydrates, 2.0 is the grams of protein, and 1.0 is the number of servings, the output is:…arrow_forwardprogramming language : C++ subject : object oriented programming question: We know that an Organization consists of Managers and Employees. You are required to create a base class Person with attributes name, CNIC and gender. Derive Manager and Employee class from Person class.arrow_forward(b) How does the static data member of a class differ from a non-static data member? Give a real-world scenario in which a static data member might be useful.arrow_forward
- c++ 1- Use UML notations to describe 4 or 5 related classes and their relationships. For each class, define the private data (variables), and the public methods (operations), and IS-A (inheritance), Has-A (Composition / Aggregation) relationships between classes. Classes related to a school and Classes related to a hospital.arrow_forwardWith appropriate examples, explain the features of static class members.arrow_forwardFinish the following programs. Define two public abstract class called ListNode and List. The ListNode class has 2 non-public fields, one called item which is of type Object and references the item stored in the current node, the other called myList which is of type List and references the list that contains this node. The List class has one non-public field, called size which is the number of items in the list. Both ListNode and List class are defined in the package called mylist and their subclasses in any package can access to both item, myLis or size. isEmpty() returns true if this list is empty, false otherwise. You can ignore the definition and use of the InvalidNodeException class. //definition of the ListNode class _______________________; _______________________ { _____________________; _____________________; public boolean isValidNode() {…arrow_forward
- Define a class for the marks (student subject marks) that includes the following data members: A (OOP) B (Data Structures) C (Calculus II) The class also contains the following member functions: Insertion function – to get three values (courses). Sum - to sum up three values (courses). Ave – to give average of the three values (courses). Display function - to display sum and average. NOTE:subject: object oriented programming(oop) Deptt:CS/ITarrow_forwardProblem Statement:We are going to develop an information system for a vehicle-related business; having various types of vehicles including cars, truck etc. Generally, every type of vehicle has a wheels, engine power, model etc. But there are some vehicles, which have specialized features other than these basic ones. E.g. Car has a small diggy and truck has a cargo bed. In this exercise, create a class Vehicle, and inherit Vehicle class in a Car and a Truck class. • Create a class named Vehicleo Data members: ModelName, RegistrationNumber, and Owner.o Default Constructoro Overloaded constructero Getter and setters.o A display() function that return a string having Vehicle details. • Create a class named Car as a derived class of the base class Vehicle.o Additional attribute is trunk (diggi) dimension in millimeters (e.g. 200X200X500mm) (data type will be string).o Default Constructoro Overloaded constructer with arguments Model Name, Registration Number,…arrow_forwardState a circumstance in which you would prefer an interface over an abstract class. Also, State a circumstance in which you would prefer an abstract class over an interface.arrow_forward
- Game of Chess in C++ The objective of this assignment is to practice concepts related to inheritance, overriding, polymorphism, and abstract classes, to program the basics of a chess playing program. About: Chess is played on an 8 X 8 board where the initial placement of pieces. The white king is on e1, and the black king is on e8. Each chess piece can move in a specific way. Follow a simplified version. Most importantly, ignore an important rule in chess: Moving any piece in a way that puts your own king in check is illegal. Since we don't know what check means, for us a move is legal if the piece we are moving has an empty square to move to or can capture (replace) an opponent's piece (including their king). The king does not move at all. Nor can it castle the queen and knight can't move either. A pawn in the initial position may move one or two squares vertically forward to an empty square but cannot leap over any piece. Subsequently it can move only one square vertically forward…arrow_forwardPart darrow_forward*Initial Class Diagram is attached below Refine the UML class diagram so that it demonstrates the following: Classes (using the complex class symbols), Associations (with multiplicities AND association names), Generalizations (if any), and Compositions (if any) Focus ONLY on the following activities within the system: Start a Trip, Reserve a Vehicle, Make a Parking Reservation, Make a Charging Session for a Personal Vehicle, End a Trip or Charging Session, and Submit a Support Ticket for a Vehicle or Station Add the primary key necessary to support any relationships that have a multiplicity of "1" as an attribute in the corresponding classarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY