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
Question
Chapter 8.1, Problem 6STQ
Program Plan Intro
Explanation for Figure 8.3:
- • The “Person” and “Student” are the two classes. The “Person” is inherited from the “Student” class. The arrow represents from the “Student” class to the “Person” class diagram.
- • The “Person” class contains “name” is a variable, and “setName”, “getName”, “writeOutput”, and “hasSameName” are the methods.
- • The “Student” contains “studentNumber” is a variable, and “reset”, “getStudentNumber”, “setStudentNumber”, “writeOutput”, and “equals” are the methods.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Test time left: 01:21:11
Write a java program to implement the concept of inheritance where the subclass StaffMember inherits the super class Department and
implements the interface Publication. Print the details of department along with their faculty details and their publication. Consider 15 faculty
members are in the dept.
Department - class
Data members: Department Name, HOD Name, total students, no of sections Methods: Constructor,
showDepartment Details()
StaffMember-class
Data members: Staff Member Name, staff id, Staff Qualification, designation, experience (all are private)
Methods: Constructor, showStaffDetail()
Publication-interface
journalcount, projectcount, patterncount
public void show_publication_detail()
Create an inheritance hierarchy that could be used to represent the following classes:accountant, customer, department, employee, manager, organization, and salesperson.
Write the classes as shown in the following class diagram. Add a tester that asks the user for a cat, dog and a BigDog then call all of their methods. Note that Cat and Dog inherit from the abstract class Animal and BigDog inherits from Dog.
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
Knowledge Booster
Similar questions
- Create an inheritance hierarchy of Rodent: mouse, gerbil, hamster, guinea pig. In the base class, provide methods that are common to all rodents based on behaviours you find with a quick Internet search. Be sure to document the behaviours you implement (e.g., eat, sleep, groom, move, etc.). Each behaviour should print its action to standard output (e.g., rodent eating). Next, refine these behaviours in the child classes to perform different behaviours, depending on the specific type of rodent, but only if the behaviour is actually different (e.g., mouse eating seeds or guinea pig eating grass) Test your Rodent classes by writing a main() class and creating instances of every rodent, and demonstrate all the behaviours for each rodent.arrow_forwardCreate an inheritance hierarchy of Rodent: mouse, gerbil, hamster, guinea pig. In the base class, provide methods that are common to all rodents based on behaviours you find with a quick Internet search. Be sure to document the behaviours you implement (e.g., eat, sleep, groom, move, etc.). Each behaviour should print its action to standard output (e.g., rodent eating). Next, refine these behaviours in the child classes to perform different behaviours, depending on the specific type of rodent, but only if the behaviour is actually different (e.g., mouse eating seeds or guinea pig eating grass) Test your Rodent classes by writing a main() class and creating instances of every rodent, and demonstrate all the behaviours for each rodent. When solving can you write comments on the code explaining it.arrow_forwardCan you write the code by java and Thank youarrow_forward
- Computer Science There are clearly some similarities in the implementations of Taxi and Shuttle that suggest use of inheritance to represent them. Introducing inheritance is the primary task of this assessment. -The Ezcab class, The Ezcab class maintains separate lists of taxis and shuttles and destinations with destination fares (you can hardcode destination fares). It has a lookup method that searches for a taxi/shuttle with a given ID. -The Taxi and Shuttle classes share some common attributes – location and destination. They also have some common methods – getLocation, getDestination, getStatus and setDestination. -Vehicle is the superclass of both Taxi and Shuttle. This class involves placing the common fields and methods into Vehicle and removing them from Taxi and Shuttle. -Modify Taxi and Shuttle class to indicate that it is a subclass of Vehicle. You can keep the id field in Vehicle class and getId,SetId methods. -Arrange for Taxi's constructor to call the constructor of…arrow_forwardInheritance in Java Instructions: Construct a class called “Rectangle”. A “Rectangle” has both a length and a width (both positive integers). Access to them should be only inside the class and within the inheritance hierarchy. Then implement the following: - lone constructor that accepts two integers for the length and the width. Prints “Rectangle Constructor” getters and setters - area - prints “Rectangle Area” and returns the area of the rectangle - perimeter - prints “Rectangle Perimeter” and returns the perimeter of the rectangle Create a class called “Square”. The square is a rectangle. Therefore, have Square inherit from Rectangle. Square construction prints “Square Constructor” and accepts one integer which is the length of a side. The version of the area and perimeter of Square prints “Square Area” and “Square Perimeter”, respectively. Inputs A positive integer representing the length of the side of a Square. 2 Sample Output Enter side length: 2 Rectangle Constructor Square…arrow_forwardInheritance and PolymorphismThis assignment starts with the Account class from Labs 4 and 5.Our new and improved bank has two kinds of accounts, savings, and checking. In addition to an ID and a balance, savings accounts have an annual interest rate and a minimum balance. Checking accounts have a minimum balance and a monthly fee. Withdrawals and deposits can be made to both kinds of accounts. At the end of each month, savings accounts pay interest, but only if the account’s balance is above the minimum. Also at the end of each month,a fee is deducted from each checking account, but the fee is waived if the account’s balance is over the minimum. Tasks1.Create a complete UML diagram which shows the relationships between the three classes, Account, Savings, and Checkingand all of the fields and methods in each. The only modificationsrequired to the Account class is the addition of two abstract methodscalled closeMonth and accountString.2.The closeMonth function performs the appropriate…arrow_forward
- Convert the UML class diagram above into a java code with the following conditions The methods in the Pet class are abstract. Create a class called test. The main() method in the test class should create three Cat objects and two Budgie The main() method should also create indirectly an object of the Pet class. Demonstrate polymorphism in your testarrow_forwardWrite a suitable inheritance program according to the following program, and print an outputarrow_forwardNeed help with this question. Put it in picture form since it is a combination of questions #7, and #8 in the picture, so inheritance is involved. All coding is done in Java, using IntelliJ Idea.arrow_forward
- Javaarrow_forwardInstructions: Write your answer on a piece of paper with your name on top. Take a picture and submit within the allocated time limit. Problem 1: Implement class Employee as illustrated below. Apply appropriate constructors, encapsulate, and override toString and equals. Student Course Problem 2: «interface Payable abstract Employee Person SalariedEmployee Idno Name Employee Superclass Department Salary Subclass getPayment Amount() firstName, lastName, SSN weeklysalary Given the class hierarchy: 1. Define the interface Payable. 2. Define the class Employee that implements Payable and encapsulate. 3. Define SalariedEmployee and encapsulate. Implement getPayment Amount(). getPayment Amount() - returns a double amount that must be paid for an object of any class that implements the interface. For SalariedEmployee, it would just return the value returned by getWeeklySalary(). for new files: 128MBarrow_forwardDraw an inheritance hierarchy for the people in your place of study or work. For example, if you are a university student, then your university probably has students (first-year students, second-year students, . . . ), professors, tutors, office personnel, etc.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,