C++ How to Program (Early Objects Version)
10th Edition
ISBN: 9780134448824
Author: Paul Deitel; Harvey M. Deitel
Publisher: Pearson Education (US)
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Java)
The Abstract Art Class
Write an abstract class as follows:
The class is named Art
It inherits from the Comparable interface
It has a private String member variable named name
It has a private String member variable named artist
It has a private int member variable called year
It has a default constructor that assigns the values "No name" to name, "No artist" to artist and -1 to the year. This default constructor calls the three argument constructor.
It has a three-argument constructor to assign values to the name, artist and year variables.
It has a copy constructor that makes a copy of another non-null Art object
It has getters and setters for the name, artist and year variables
It has a toString() method that creates a string of artist, with name and year tabbed once on subsequent lines (see sample output)
It has an equals method that compares this Art to another Object
It has a compareTo method that compares in this order: 1) artist, 2) name, 3) year
This class contains no…
(Triangle class) Design a new Triangle class that extends the abstract GeometricObject class.
Draw the UML diagram for the classes Triangle and GeometricObject and then implement
the Triangle class. Write a test program that prompts the user to enter three sides of the
triangle, a colour, and a Boolean value to indicate whether the triangle is filled. The program
should create a Triangle object with these sides and set the colour and filled properties using
the input. The program should display the area, perimeter, colour, and true or false to indicate
whether it is filled or not.
(Triangle class) Design a new Triangle class that extends the abstract
Geometricobject class. Draw the UML diagram for the classes Triangle and
Geometricobject then implement the Triangle class. Write a test program
that prompts the user to enter three sides of the triangle, a color, and a Boolean
value to indicate whether the triangle is filed. The program should create a Tri-
angle object with the se sides, and set the color and filled properties using the
input. The program should display the area, perimeter, color, and true or false to
indicate whether it is filled or not.
Chapter 12 Solutions
C++ How to Program (Early Objects Version)
Ch. 12 - (Programming in the General) How is it that...Ch. 12 - (Polymorphism vs. switch logic) Discuss the...Ch. 12 - (Inheriting Interface vs. Implementation)...Ch. 12 - Prob. 12.6ECh. 12 - Prob. 12.7ECh. 12 - Prob. 12.8ECh. 12 - Prob. 12.9ECh. 12 - (Polymorphic Application) You've been asked to...Ch. 12 - (Payroll-System Modification) Modify the payroll...Ch. 12 - Prob. 12.12E
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
- (The Time class) Design a class named Time. The class contains: - The data fields hour, minute, and second that represent a time. - A no-arg constructor that creates a Time object for the current time. (The values of the data fields will represent the current time.) -A constructor that constructs a Time object with a specified elapsed time since midnight, January 1, 1970, in milliseconds. (The values of the data fields will represent this time.) -A constructor that constructs a Time object with the specified hour, minute, and second. - Three getter methods for the data fields hour, minute, and second, respectively. -A method named setTime (long elapseTime) that sets a new time for the object using the elapsed time. For example, if the elapsed time is 555550000 milliseconds, the hour is 10, the minute is 19, and the second is 10. Draw the UML diagram for the class and then implement the class. Write a test program that creates two Time objects (using new Time (), new Time(555550000),…arrow_forward(Java) The Sculpture Subclass Write class as follows: The class is named Sculpture, and it inherits from the Painting class. It has a private boolean member variable named humanForm It has a default constructor that assigns the values "No name" to name, "No artist" to artist, -1 to the year, "No medium" to the medium, and false to the humanForm variable. This default constructor calls the five argument constructor. It has a five-argument constructor to assign values to the name, artist, year, medium, and humanForm variables. It has a getter and setter for the humanForm variable. It has a toString() method. This class contains no other methods Make sure to include your name, the name of this class, our course number, and the Activity number in a Javadoc comment at the top. Make sure to write a Javadoc comment for each of these methods.arrow_forward(CarbonFootprint Abstract Class: Polymorphism) Using an abstract class with only pure virtual functions, you can specify similar behaviors for possibly disparate classes. Governments andcompanies worldwide are becoming increasingly concerned with carbon footprints (annual releasesof carbon dioxide into the atmosphere) from buildings burning various types of fuels for heat, vehicles burning fuels for power, and the like. Many scientists blame these greenhouse gases for the phenomenon called global warming. Create three small classes unrelated by inheritance—classesBuilding, Car and Bicycle. Give each class some unique appropriate attributes and behaviors thatit does not have in common with other classes. Write an abstract class CarbonFootprint with onlya pure virtual getCarbonFootprint method. Have each of your classes inherit from that abstract classand implement the getCarbonFootprint method to calculate an appropriate carbon footprint forthat class (check out a few websites that…arrow_forward
- (Composition as an Alternative to Inheritance) Many programs written with inheritancecould be written with composition instead, and vice versa. Rewrite class BasePlusCommissionEmployee of the CommissionEmployee–BasePlusCommissionEmployee hierarchy to use compositionrather than inheritance. After you do this, assess the relative merits of the two approaches for designing classes CommissionEmployee and BasePlusCommissionEmployee, as well as for object-oriented programs in general. Which approach is more natural? Why?arrow_forward(Java) Question 5 Explain the answer step-by-step and include verbal explanation. Thank you! Write an interface as follows: The interface is named ServiceReminder It has one method named timeForService that has no parameters and returns a boolean variable. Now, update the below class so that is inherits from ServiceReminder Note that the next service date should be 90 days from the last service public abstract class Car { private double gasGauge; private double currMileage; private String color; private String make; private String model; private int daysLastService; public Car(String color, String make, String model, int daysLastService) { this.color = color; this.make = make; this.model = model; gasGauge = 0.0; currMileage = 0.0; this.daysLastService = daysLastService; } @Override public String toString() { return "Make: " + make + "\nModel: " + model + "\nColor: " + color…arrow_forward(The Account class) Account -id: int -balance: double -annualInterestRate : double -dateCreated : Date +Account( ) +Account(someId : int, someBalance : double) +getId() : int +setId(newId : int) : void +getBalance() : double +setBalance(newBalance : double) : void +getAnnualInterestRate( ) : double +setAnnualInterestRate(newRate : double) : void +getDateCreated( ) : Date +getMonthlyInterestRate( ) : double +getMonthlyInterest( ) : double +withdraw(amt : double) : void +deposit(amt : double) : void Design a class named Account that contains: ■ A private int data field named id for the account (default 0). ■ A private double data field named balance for the account (default 0). ■ A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. Make it static. ■ A private Date data field named dateCreated that stores the date when the account was created. (private Date dateCreated)…arrow_forward
- Problem (Online Address Book): Using classes, design an online address book to keep track of the names, addresses, phone numbers, and dates of birth of family members, close friends, and certain business associates. Define a class addressType that can store a street address, city, state, and ZIP code. Use the appropriate functions to print and store the address. Also, use constructors to automatically initialize the member variables. Define a class extPersonType using the class personType with following members and methods: firstname, lastname, and accessors and mutators, print to display, and constructors. Define a class dateType for month, day and year as members with its accessors, mutators, and constructors) Design a class addressType. Add a member variable to this class to classify the person as a family member, friend, or business associate. Also, add a member variable to store the phone number. Add (or override) the functions to print and store the appropriate information.…arrow_forward(The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date hired. Use the MyDate class defined in Programming Exercise 10.14 – see the textbook - to create an object for date hired. A faculty member has office hours and a rank. A staff member has a title. Override the toString method in each class to display the class name and the person's name. Draw the UML diagram for the classes and implement them. Write a test program that creates a Person, Student, Employee, Faculty, and Staff, and invokes their toString() methods.arrow_forwardWhat are the three things you need to do when working with classes that include pointer variables as member variables?arrow_forward
- use java to answerand Thank youarrow_forwardNutritional 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_forward(java) The Painting Subclass Write class as follows: The class is named Painting, and it inherits from the Art class. It has a private String member variable named medium It has a default constructor that assigns the values "No name" to name, "No artist" to artist, -1 to year, and "No medium" to the medium variable. This default constructor calls the four-argument constructor. It has a four-argument constructor to assign values to the name, artist, year, and medium variables. It has a getter and settersfor the medium variable. It has a toString() method This class contains no other methods Make sure to include your name, the name of this class, our course number, and the Activity number in a Javadoc comment at the top. Make sure to write a Javadoc comment for each of these methods.arrow_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
What is Abstract Data Types(ADT) in Data Structures ? | with Example; Author: Simple Snippets;https://www.youtube.com/watch?v=n0e27Cpc88E;License: Standard YouTube License, CC-BY