Create a new class called Dog that is derived from the Pet class given in Listing 6.1 of Chapter 6. The new class has the additional attributes of breed (type string) and boosterShot (type boolean), which is true if the pet has had its booster shot and false if not. Give your classes a reasonable complement of constructors and accessor methods. Write a driver
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
SURVEY OF OPERATING SYSTEMS
Concepts Of Programming Languages
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out with Python (4th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
- Give source code and output alsoarrow_forwardHelp, I making a elevator simulator, I need help in writing code in the Elevator class and it's polymorphism class. I am not sure what to do next. Any help is appreciated. There are 4 types of passengers in the system:Standard: This is the most common type of passenger and has a request percentage of 70%. Standard passengers have no special requirements.VIP: This type of passenger has a request percentage of 10%. VIP passengers are given priority and are more likely to be picked up by express elevators.Freight: This type of passenger has a request percentage of 15%. Freight passengers have large items that need to be transported and are more likely to be picked up by freight elevators.Glass: This type of passenger has a request percentage of 5%. Glass passengers have fragile items that need to be transported and are more likely to be picked up by glass elevators. There are 4 types of elevators in the system:StandardElevator: This is the most common type of elevator and has a request…arrow_forwardCreate a Right Triangle class that has two sides. Name your class rightTraingle. Code getter and setters for the base and the height. (Remember class variables are private.) The class should include a two-argument constructor that allows the program to set the base and height. The constructor should verify that all the dimensions are greater than 0. before assigning the values to the private data members. If a side is not greater than zero, set the value to -1. The class also should include two value-returning methods. One value-returning method should calculate the area of a triangle, and the other should calculate the perimeter of a triangle. If either side is -1, these functions return a -1. The formula for calculating the area of a triangle is 1/2 * b*h, where b is the base and h is the height. The formula for calculating the perimeter of a triangle is b+h+sqrt (b*b+h*h). Be sure to include a default constructor that initializes the variables of the base, height to -1. To test…arrow_forward
- Note: Write a Java program given below Question # 1: Define a class for Students with field name, age, marks. Define getter and setter for all the fields. In the setter method, if age is less than 0, print that Age is less than zero. Similarly, if marks is less than zero or greater than 100, print in correct marks and don’t assign marks to member variable. In the Test class, create student’s object and assign the marks and age to appropriate values. Try assigning incorrect values to check if getter and setter methods work as expected.arrow_forwardWrite a program that accepts two numbers. Use Scanner class to get the user input. Create 4 classes, the first one is the Main Class that has the main method, the other three classes are Su m, Subtract and Multiply. These three classes should have their constructors which has a parameter of type int. Create a method for each class that returns the result of the computation of two numbers. In the main method, after accepting the user input, it should call the three methods from the three classes and display its result.arrow_forwardDesign a class called "Person" with attributes for name, age, and gender. Implement methods to get and set these attributes, and also a method to calculate the person's age in dog years (assuming 1 dog year is equivalent to 7 human years).arrow_forward
- Give Solutionarrow_forwardYou are going to be working with class Rational which defines rational number objects. A rational number is a number that can be written as a fraction. A rational number consists of a numerator and a denominator (which cannot be 0). Rational numbers also have the ability to be displayed in an original form, decimal form or reduced form. You are going to be completing various object methods to perform the tasks previously list. You are to begin with the Rational Class and RationalTest classes provided. Make all modifications outlined in the point values below. Pay close attention to the names of the attributes, methods and return values. You are given starter files and the test files necessary. Only modify class Rational and keep the function headers provided to you for all of Part 1. You will need to add your own methods for Part 2. Part 1a This version requires that you complete the constructor, getOriginal(), and getDecimal() methods of class Rational. Constructor: at this stage…arrow_forwardYour task is to write a program that computes paychecks. Employees are paid an hourly rate for each hour worked; however, if they worked more than 40 hours per week, they are paid at 150 percent of the regular rate for those overtime hours. Name an actor class that would be appropriate for implementing this program . Then name a class that isn't an actor class that would be an appropriate alternative. How does the choice between these alternatives affect the program structure? Implement the appropriate class and solve the problem. You need to test your code using a separate main class program named "exel.java” Javaarrow_forward
- Create a Book class with attributes such as book title, author, and price. Implement a parameterized constructor to initialize these attributes. Now, extend the functionality of the Bookstore class by adding a new method called 'addBook.' This method should allow the addition of custom books to the bookstore's inventory. The method should take three parameters: title, author, and price. Implement this method to ensure that the bookstore's inventory is updated accordingly. Instantiate a new object of the bookstore, naming it 'ReadersHaven, utilizing the extended class with the newly added 'addBook' method. Your next step is to add three distinct custom books to 'ReadersHaven-for example, 'The Silent Observer® by Jane Doe, priced at $20.99, Adventures in Wonderland" by Lewis Carroll, priced at $15.50, and 'Programming Mastery by John Coder, priced at $30.75. To conclude, utilize a 'displayinventory' method to showcase the updated information about 'ReadersHaven." Verify that the output…arrow_forwardDefine a class called Country. A Country has population S ize, area, capital, currency, and abbreviation ( (2-3 letters taken from the country name). Define at least two constructors, at least two getter methods, at least two setter methods, and Override the toString() method and the equals() method. The equals() method must return true if the two countries have the same name and same area and false otherwise The abbreviation is the first letter and the letter before the last of the country name and must be generated automatically eg if the country name is Palestine the abbreviation is PN, if the country name is Jordan the abbreviation is JA) Write a main method, define an array of country objects, read countries data from the user, if two countries have the same abbreviation add the last letter from the country name to the abbreviation o one million. f the country inserted last Display countries whose populationSize is greater thanarrow_forwardNot all dogs like to bark, but some like to make a lot of noise! In this exercise we have a Dog superclass and a LoudDog subclass. You do not need to modify the Dog class. Your task is to write two override methods in the LoudDog class. You will override the speak method to return BARK!. You will then override the toString so that it returns Clover is loud and likes to BARK! where Clover is replaced by the name variable. Create and print at least one Dog and one LoudDog to test. public class DogTester{public static void main(String[] args){// Start here}} public class Dog{private String name;public Dog(String name){this.name = name;}public String getName(){return name;}public String speak(){return "Bark!";}public String toString(){return name + " likes to " + speak();}} public class LoudDog extends Dog{public LoudDog(String name){super(name);}// Override the speak method here//Override the toString here.//Remember, you can access the name using super.getName()}arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education