Define a class called Diamond that is derived from either the class ShapeBasics (Listing 8.12) or the abstract class ShapeBase (Listing 8.19) A diamond has the same sort of top half as a Triangle object, and its bottom half is an inverted version of its top half. Define a utility class having public static methods, such as the method skipSpace and other methods that draw horizontal lines, big V’s, and inverted big V’s Recall that Self-Test
Question 31 asked you to describe one method m this class.
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)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Mechanics of Materials (10th Edition)
Starting Out With Visual Basic (8th Edition)
- Define a class named Doctor whose objects are records for a clinic’s doctors. Derive this class from the class Person given in Listing 8.1. A Doctor record has the doctor’s name—defined in the class Person—a specialty as a string (for example Pediatrician, Obstetrician, General Practitioner, and so on), and an office-visit fee (use the type double). Give your class a reasonable complement of constructors and accessor methods, and an equals method as well. Write a driver program to test all yourmethods.arrow_forwardPls help on this questions ASAParrow_forward5. Given the Java Point class (which contains two private variables x and y and constructors that allows creating a point object with known x and y values as well as other methods such as equals( ), toString( ) etc), (a). define a new class called Circle that contains private two variables: center which is a Point object from the Point class and radius which is of type double. The Circle class must have the following methods: (b). add a constructor which creates a circle object using a center point with x and y values and a radius as its parameters. (c). add a default constructor. ( (d). add an equals() method that can compare if any object is equal to a Circle object (two circle objects are equal if they have the same center point with the same radius). (e). add a toString() method that prints a Circle object with the center point and radius.arrow_forward
- Design and implement a class called Car that contains instance data that represents the make, model, and year of the car (as a String, String and int value respectively). Define the Car constructor to initialize these values (in that order). Include getter and setter methods for all instance data, and a toString method that returns a one-line description of the car of the form make-model (year)for example:Ford-Thunderbird (1955)arrow_forwardMake a class Employee with a name and salary. Make a class Manager inherit from Employee. Add an instance variable, named department, of type string. Supply a method tostring that prints the manager's name, department, and salary. Make a class Executive inherit from Manager. Supply appropriate tostring methods for all classes. Supply a test program that tests these classes and methods.arrow_forwardplease solve it with java and put screenshots of the codearrow_forward
- Write a java program Write a class named Employee with name and salary as private data fields. Add a constructor with both parameters. Write a class named Manager which unherits the Employee class. Add an instance variable, named department, of type String and 15 private. Add a constructor in the subclass class and a toString () method that prints the manager's name, department, and salary [Hint: Add a tastanel) method in the super class as well]. Create objects of Manager and Employee dassarrow_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_forwardJAVA Write the class Rectangle. A Rectangle is a Shape and should have a width and a height. Refers to this : Write an abstract class for Shape. The intended subclasses are Polygon, Circle, Triangle, and Rectangle. All of these will have a name, an area, and a perimeter. (Consider which methods might be abstract.) Add a toString method that will return the information about the Shape, for example: Triangle, Area: 7.5, Perimeter: 12.0arrow_forward
- Task: 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_forwardImplement the following using JAVA: a.Design a class named Person and its two subclasses named Student andEmployee. b.Make Faculty and Staff subclasses of Employee. Please note that,● A person has a name, address, phone number, and email address. A student has aclass status (freshman,sophomore, junior, or senior). You can define the status as aconstant.● An employee has office & salary.● A faculty member has office hours and a rank.● A staff member has a title. c. Draw a UML diagram of the system.arrow_forwardMake a class Person, with instance variable name, age, and gender. Make a class Employee inheritfrom Person, with extra data for salary, and hiring date. Make another class Student inherit from Person,with data for program name, level (undergraduate/graduate), and program year. Supply required methods forthe superclass and the subclasses. Make a subclass Manager from Employee, with bonus salary, andoverride the corresponding method(s). Provide toString method for the Employee class and its subclass,Manager, such that it returns employee name, type of the employment, and salary. For instance if you createan object, manager1, from Manager class, with name=”John Smith” and annual salary of $125,000 and bonusweekly bonus of $200, and then write a print statement like System.out.println(manager1); , the output willbe:John Smith, Manager, Salary = $125,000/year, Weekly bonus = $200arrow_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