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
Web Development and Design Foundations with HTML5 (8th Edition)
Starting Out with Python (4th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Using MIS (10th Edition)
Database Concepts (8th Edition)
- 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_forwardWrite 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_forward
- JAVA 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_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_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
- a:) Define a Polygon interface that has methods area() and perimeter(). b:) Then implement classes for Triangle, Quadrilateral, Pentagon, Hexagon, and Octagon, which implement this interface, with the obvious meanings for the area() and perimeter() methods. c:) Implement classes, IsoscelesTriangle, Equilateral-Triangle, Rectangle, and Square, which have the appropriate inheritance relationships. d:) Write a simple user interface, which allows users to create polygons of the various types, input their geometric dimensions, and then output their area and perimeter. e:) For extra effort, allow users to input polygons by specifying their vertex coordinates and be able to test if two such polygons are similar. using all a to e parts develop a programarrow_forwardJava program * Interfaces 1. Modify the class Rectangle to implement the Comparable interface, as shown in the following UML class diagrams. Apply the required changes in the class’s header.2. Then, in the Rectangle class override the method compareTo(), so if this object’s area is greater than the specified (given through the parameter) object’s area return 1, if it is less than return -1, and 0 otherwise. 3. Create a test class named Test2. Then complete the following tasks: a. Create an ArrayList and add to it 4 Rectangle objects with different width and height values. b. Print out the elements of the ArrayList. c. Sort the elements of the ArrayList using the static method sort of the class java.long.Collections. This would be possible only, if you implemented the method compareTo() correctly in the Rectangle class. d. After sorting the elements of the ArrayList, print the elements again. 4. Run the Test class. Here is the rectangle's class program public class Rectangle extends…arrow_forwardCreate an interface Wheel with methods setWheels (int c) and getWheels () and a class Vehicle with abstract methods getColor () and getBrand (). Now, create a concrete class Taxi with additional method setDriver (String name) that inherits both Wheel and Vehicle. (Note: Concrete classes don’t have any abstract method)arrow_forward
- Java- 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_forwardCreate a class BeautyProduct with name, color, brand. Provide Constructors, getters, setters and also write toString method. Now create a class Lipstick which extends the class BeautyProduct as Lipstick is-a Beauty Product it has totalVolume, remainingVolume, price, texture (gloss, matt) as private data members. Provide Constructors, getters, setters and an apply() method whenever this method is called a beauty item is applied and its volume decreases by 10.This should also check that volume must not be zero if it then u have to throw exception. Also write toString method which prints all details like name, color, brand, price, texture and volume. Create another class foundation having totalVolume, remainingVolume, price, texture (liquid, cake) and lastingTime (number of hours foundation remain intact on face and does not crease) as private data members. This also extends the base class i.e. BeautyProduct. Provide Constructors, getters, setters and an apply() method whenever this…arrow_forwardWrite a class named Employee which implements Comparable Interface with name and salary as data fields Add a constructor with argument name and salary. Add getter and Setter for name and salary. Add CompareTo() method for the data Salary. Write a class named Manager which inherits the Employee class. Add an instance variable, named department, of type String. Add a constructor in the subclass class with arguments name, salary, department and a toString() method that prints the manager’s name, department, and salary [Hint: Add a toString( ) method in the super class as well] Create 3 objects of Manager with following arguments 1. (Zayed, 500), 2. ( Ahmed, 700) 3. ( Faisal, 600) Add the above 3 objects into an ArrayLIst object and Sort by Salary and Display. Create an object Employee class with (Zayed, 500,IT) and display the 1. Name 2. Salary 3. Department by using tostring() method.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