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
write this java code
Inheritance 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…
Implement the following parking permit class using java
It has a dependency on the car class, no need to implement the car class.
Use the diagram for refrence
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
- Write a suitable inheritance program according to the following program, and print an outputarrow_forwardJavaarrow_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_forward
- Do it in C# windows application form.arrow_forwardWrite the Talker interface, Animal abstract class, plus the Dog, Cat, Fish, and Radio classes for this Java Program. Talker.java - the interface Talker, which has just one void method called speak() Animal.java - the abstract class Animal, which stores an animal's name. (No abstract methods). It should contain 2 methods: a constructor with 1 argument (the name) a method getName() which returns the name. Dog.java - the class Dog, which extends Animal and implements Talker. It should contain 3 methods: a constructor with no arguments, giving the dog a default name of "Fido" a constructor with 1 argument (the name) a speak() method that prints "Woof" on the screen. Use @Override Cat.java - the class Cat, which extends Animal and implements Talker. It should contain just 2 methods: a constructor with 1 argument (the name) (no default name like dogs have) a speak() method that prints "Meow" on the screen. Use @Override Fish.java - the class Fish, which is an Animal that…arrow_forwardyou are given an OOP UML diagram. You will implement it in Java using OOP concepts like encapsulation, inheritance and polymorphism.arrow_forward
- Write in java an abstract class Student that includes the following hidden attributes: id(int), name(String), major(String) and grade(double), then create setter and getter for each of them. Write two classes that inherited from Student: ItStudent and ArtStudent. The grade for ItStudent is calculated as: grade = mid*0.30 + project*0.30 + final*40 and the grade for ArtStudent is calculated as: grade = mid*0.40 + report*0.10 + final*50. Crate main class that achieve the following:a. Create an array of some Student objects from both ItStudent and ArtStudent classes.b. Sort the Student objects by grade in descending order using functions.c. Save the sorted objects into file.arrow_forwardDifferentiate the concept of inheritance and interface in kotlin by writing kotlin code. (note: You can use two different codes then explain the difference)arrow_forwardJava- Suppose that Vehicle is a class and Car is a new class that extends Vehicle. Write a description of which kind of assignments are permitted between Car and Vehicle variables.arrow_forward
- Write an abstract class, it can be anything well defined from the very basics.arrow_forwardWhat is the design pattern depicted in the diagram below? The intent of this design pattern is to define an interface for creating an object, but let subclasses decide which class to instantiate. It lets a class defer instantiation to subclasses. Client Abstraction normalMethodoe BmakeObjecto Product do some stuff aProduct = makeObjecto: f do some more stuff -aProduct Product ConcreteOne ConcreteTwo makeObjecto : Product ProductOne ProductTwo return new ProductOneo. A. Factory Method Design Pattern B. Singleton Design Pattern C. Proxy Design Pattern D. Adapter Design Patternarrow_forwardTask: Implement a class ChessPiece with properties: color, isAlive, moveCount, and position (x, y coordinates). Define an abstract move method. Create a Tower subclass that overrides move for specific behavior. Instructions: ChessPiece Class: Properties: String color, boolean isAlive, int moveCount, Position position. Abstract Method: move(int x, int y). Position Class: Contains int x, int y. Tower Subclass: Extends ChessPiece. Overrides move for straight line movement. Deliverable: Source code for ChessPiece, Position, and Tower. Document class functionalities briefly.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,