Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 8.1, Problem 2STQ
Suppose the class SportsCar is a derived class of a class Automobile. Suppose also that the class Automobile has private instance named speed, manufacturer, and numberOfCylinders. Will an object of the class SportsCar have instance variables named speed, manufacturer, and numberOfCylinders?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Suppose the class SportsCar is a derived class of a class Automobile.Suppose also that the class Automobile has private instance variablesnamed speed, manufacturer, and numberOfCylinders. Will an object ofthe class SportsCar have instance variables named speed, manufacturer,and numberOfCylinders?
Consider the PlayingCard, Rank and Suit classes.
a)Which two classes are instance variables in the third class?
b)Are instance variables an is-a or has-a relationship?
A class called Customer (as shown in the class diagram above) is designed to model a customer. It contains:
Three private instance variables: id (int), name (string), and discount (int)
One constructor to initialize the id, name and discount with the given values;
Customer (int ID, string Name, int Discount) {......}
(There is no default constructor for Customer, as there are no defaults for the data.)
public getters/setters: getID (), getName(), and getDiscount();
setDiscount (int) – to set the value for the customer’s discount rate.
toString() method that returns the string of all the data for the customer
Provide additional function :
calcDiscountPrice (float price) method that calculates and returns the discounted price sent through the parameter, based on the customer’s discount rate for the Customer.
Write the complete Customer class using C++ based on the above description. Then do the following :
Declare three Customer objects and insert the data using the…
Chapter 8 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 8.1 - Prob. 1STQCh. 8.1 - Suppose the class SportsCar is a derived class of...Ch. 8.1 - Suppose the class SportsCar is a derived class of...Ch. 8.1 - Can a derived class directly access by name a...Ch. 8.1 - Can a derived class directly invoke a private...Ch. 8.1 - Prob. 6STQCh. 8.1 - Suppose s is an object of the class Student. Base...Ch. 8.2 - Give a complete definition of a class called...Ch. 8.2 - Add a constructor to the class Student that sets...Ch. 8.2 - Rewrite the definition of the method writeoutput...
Ch. 8.2 - Rewrite the definition of the method reset for the...Ch. 8.2 - Can an object be referenced by variables of...Ch. 8.2 - What is the type or types of the variable(s) that...Ch. 8.2 - Prob. 14STQCh. 8.2 - Prob. 15STQCh. 8.2 - Consider the code below, which was discussed in...Ch. 8.2 - Prob. 17STQCh. 8.3 - Prob. 18STQCh. 8.3 - Prob. 19STQCh. 8.3 - Is overloading a method name an example of...Ch. 8.3 - In the following code, will the two invocations of...Ch. 8.3 - In the following code, which definition of...Ch. 8.4 - Prob. 23STQCh. 8.4 - Prob. 24STQCh. 8.4 - Prob. 25STQCh. 8.4 - Prob. 26STQCh. 8.4 - Prob. 27STQCh. 8.4 - Prob. 28STQCh. 8.4 - Are the two definitions of the constructors given...Ch. 8.4 - The private method skipSpaces appears in the...Ch. 8.4 - Describe the implementation of the method drawHere...Ch. 8.4 - Is the following valid if ShapeBaSe is defined as...Ch. 8.4 - Prob. 33STQCh. 8.5 - Prob. 34STQCh. 8.5 - What is an advantage of having the main...Ch. 8.5 - What Java construct allows us to define and...Ch. 8 - Consider a program that will keep track of the...Ch. 8 - Implement your base class for the hierarchy from...Ch. 8 - Draw a hierarchy for the components you might find...Ch. 8 - Suppose we want to implement a drawing program...Ch. 8 - Create a class Square derived from DrawableShape,...Ch. 8 - Create a class SchoolKid that is the base class...Ch. 8 - Derive a class ExaggeratingKid from SchoolKid, as...Ch. 8 - Create an abstract class PayCalculator that has an...Ch. 8 - Derive a class RegularPay from PayCalculator, as...Ch. 8 - Create an abstract class DiscountPolicy. It should...Ch. 8 - Derive a class BulkDiscount from DiscountPolicy,...Ch. 8 - Derive a class BuyNItemsGetOneFree from...Ch. 8 - Prob. 13ECh. 8 - Prob. 14ECh. 8 - Create an interface MessageEncoder that has a...Ch. 8 - Create a class SubstitutionCipher that implements...Ch. 8 - Create a class ShuffleCipher that implements the...Ch. 8 - Define a class named Employee whose objects are...Ch. 8 - Define a class named Doctor whose objects are...Ch. 8 - Create a base class called Vehicle that has the...Ch. 8 - Create a new class called Dog that is derived from...Ch. 8 - Define a class called Diamond that is derived from...Ch. 8 - Prob. 2PPCh. 8 - Prob. 3PPCh. 8 - Prob. 4PPCh. 8 - Create an interface MessageDecoder that has a...Ch. 8 - For this Programming Project, start with...Ch. 8 - Modify the Student class in Listing 8.2 so that it...Ch. 8 - Create a JavaFX application that uses a TextField...Ch. 8 - Prob. 10PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
In the following exercises, write a program to carry out the task. The program should use variables for each of...
Introduction To Programming Using Visual Basic (11th Edition)
The ________ object is assumed to exist and it is not necessary to include it as an object when referring to it...
Web Development and Design Foundations with HTML5 (8th Edition)
What are some of the difficulties or limitations encountered in heat treating large, complex structures after w...
Degarmo's Materials And Processes In Manufacturing
Sum of Numbers Design a program with a loop that asks the user to enter a series of positive numbers. The user ...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Write a summary list of the problem-solving steps identified in the chapter, using your own words.
BASIC BIOMECHANICS
What is the disadvantage of having too many features in a language?
Concepts Of Programming Languages
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
- NOTE: READ CAREFULLY Design a class named Person and a subclasses named Employee. Make Teacher a subclass of Employee. A Person has a name, address, and e-mail address. An Employee has an office, salary. A Teacher has office hours and a subject they teach. They also have a tenure status. Define the tenure status as a constant. The tenure status is either Senior or Junior, and is represented as an integer, where Senior is equal to 1, and Junior is equal to 2. Each class should have a Default constructor, and a constructor that accepts all arguments. There should be appropriate calls to the superclass within the constructors. Each class should also have getters and setters for each member variable. Each class should have a toString method. Note: You do NOT need to run this in a test program. Just create the classes as indicated above.arrow_forwardTable 1: Class Attributes name, registration number, engine number, chassis number, city of registrat make and model, color, the date of the registration, price, the date of arrival of car to the dealership, type of the vehicle, and whether the car is sold or not. dealer's name, dealer's id, dealer's address, and the dealer's phone number. dealer object also keeps track of the cars that the dealer has. A person has a name, address, phone number and e-mail address. Car Dealer Personarrow_forwardConsider a base class named Employee and its derived classes HourlyEmployee and PermanentEmployee while taking into account the following criteria.• Employee class has two data fields i.e. a name (of type string) and specific empID (of type integer)• Both classes (HourlyEmployee and PermanentEmployee) have an attribute named hourlyIncome• Both classes (HourlyEmployee and PermanentEmployee) have three-argumentconstructor to initialize the hourlyIncome as well as data fields of the base class• Class HourlyEmployee has a function named calculate_the_hourly_income to calculate the income of an employee for the actual number of hours he or she worked. One hour income is Rs. 150 • Similarly, PermanentEmployee class has function named calculate_the_income to calculate the income of an employee that gets paid the salary for exact 240 hours, no matter how many actual hours he or she worked. Again, one hour salary is Rs. 150.Implement all class definitions with their respective constructors to…arrow_forward
- The State Patrol Ticket-Processing System (Revisited 2. List the classes that would be involved in the use cases and decide which class should be responsible for collaborating with the other classes for the use case Record a traffic ticket. Consider some possibilities: A Driver object should be responsible for recording his/her ticket, the Officer object should be responsible for recording the ticket that he or she writes, and a Ticket object should be responsible for recording itself.arrow_forwardSuppose that class Child extends class Parent, and that Parent does not explicitly extend another class. Suppose also that Child has THREE constructors and Parent has TWO constructors. When creating a Child object, Child c = new Child(...), what is the minimum and maximum number of constructors being called in total?arrow_forwardCreate an abstract class named capstone with necessary abstract methods in Package 1 and define classes like Inhouse, PAT_Internship and NonPAT_Internship with required data members in sub package 1. Get a choice from student and based on the input from student, create parent reference to hold the respective child object and print the details in Package 2.arrow_forward
- Please written by hand solution In a particular factory, a shift supervisor is a salaried employee who supervises a shift. In addition, the shift supervisor earns a yearly bonus when their shift meets production goals. Write a private ShiftSupervisor class that is a subclass of the Employee class from problem 1. The ShiftSupervisor class should keep a data attribute for annual salary and data attribute for the annual production bonus that a shift supervisor has earned. Demonstrate the class by writing a program that uses a ShiftSupervisor object (create an object and display all the attributes). PYTHON ONLYarrow_forwardjust mention the Anwsers. Explanation is not needed. Thank youarrow_forwardConsider five classes i.e. Professor, Researcher, Department, Laboratory, and University having following specifications. Class University has Two attributes of type string i.e. universityName and location An attribute named dept of type Department Class Department has Two attributes i.e. deptID, deptName A two-argument constructor to initialize data fields with user-defined values A member function display() to show all attribute values Class Laboratory contains Two attributes i.e. labID and experimentNo A two-argument constructor to initialize data member with user-defined values Class Professor has A data field named profName of type string A data field named dept of type Department A two-argument constructor to initialize both attributes of user-defined values Class Researcher has A data field named profName of type string A data field named dept of type Department An attribute named lab of type Laboratory A constructor to initialize lab with user-defined…arrow_forward
- So, what are "static members" of a class, exactly? To what extent and when may you benefit from them?arrow_forwardThis programming problem consists of two parts and shall lead you through all the concepts involved in OOP Composition. Part 1: A class called Author (as shown in the class diagram) is designed to model a book's author. It contains: Three private instance variables: name (String), email (String), and gender (char of either 'm' or 'f'); One constructor to initialize the name, email and gender with the given values;public Author (String name, String email, char gender) {......}(There is no default constructor for Author, as there are no defaults for name, email, and gender.) public getters/setters: getName(), getEmail(), setEmail(), and getGender();(There are no setters for name and gender, as these attributes cannot be changed.) A toString() method that returns "Author[name=?,email=?,gender=?]", e.g., "Author[name=Tan Ah Teck,email=ahTeck@somewhere.com,gender=m]". Write the Author class. Also, write a test driver (for testing purpose on your local machine) called TestAuthor to test…arrow_forwardA class called Author (as shown in the class diagram) is designed to model a book's author. It contains: Three private instance variables: name (String), email (String), and gender (char of either 'm' or 'f'); One constructor to initialize the name, email and gender with the given values; public Author (String name, String email, char gender) {......} (There is no default constructor for Author, as there are no defaults for name, email and gender.) public getters/setters: getName(), getEmail(), setEmail(), and getGender();(There are no setters for name and gender, as these attributes cannot be changed.) A toString() method that returns string representation of author. A class called Book is designed (as shown in the class diagram) to model a book written by one author. It contains: Four private instance variables: name (String), author (of the class Author you have just created, assume that a book has one and only one author), price (double), and qty (int); Two constructors:…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 LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
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