(The Colorable interface) Design an interface named Colorable with a void method named howToColor (). Every class of a colorable object must implement the Colorable interface. Design a class named Square that extends GeometricObject and implements Colorable. Implement howToColor to display the message Color all four sides. The Square class contains a data field side with getter and setter methods, and a constructor for constructing a Square with a specified side. The Square class has a private double data field named side with its getter and setter methods. It has a no-arg constructor to create a Square with side 0, and another constructor that creates a Square with the specified side.
Draw a UML diagram that involves Colorable, Square, and GeometricObject. Write a test program that creates an array of five GeometricObjects. For each object in the array, display its area and invoke its howToColor method if it is colorable.
Trending nowThis is a popular solution!
Chapter 13 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Database Concepts (7th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
C++ How to Program (10th Edition)
Concepts Of Programming Languages
- java / eclipse pleasearrow_forwardplease solve it with java and put screenshots of the codearrow_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
- Please help me with this , I am stuck ! PLEASE WRITE IT IN C++ Thanks 1) bagUnion: The union of two bags is a new bag containing the combined contents of the original two bags. Design and specify a method union for the ArrayBag that returns as a new bag the union of the bag receiving the call to the method and the bag that is the method's parameter. The method signature (which should appear in the .h file and be implemented in the .cpp file is: ArrayBag<T> bagUnion(const ArrayBag<T> &otherBag) const; This method would be called in main() with: ArrayBag<int> bag1u2 = bag1.bagUnion(bag2); Note that the union of two bags might contain duplicate items. For example, if object x occurs five times in one bag and twice in another, the union of these bags contains x seven times. The union does not affect the contents of the original bags. Here is the main file: #include <cstdlib>#include <iostream>#include "ArrayBag.h"using namespace std; template…arrow_forwardClasses and Objects) Hand-write a complete Java class that can be used to create a Car object as described below. a. A Vehicle has-a: i. Registration number ii. Owner name iii. Price iv. Year manufactured b. Add all instance variables C. The class must have getters and setters for all instance variables d. The class must have two constructors, a no-args and a constructor that receives input parameters for each instance variable.arrow_forward(The Account class) Account -id: int -balance: double -annualInterestRate : double -dateCreated : Date +Account( ) +Account(someId : int, someBalance : double) +getId() : int +setId(newId : int) : void +getBalance() : double +setBalance(newBalance : double) : void +getAnnualInterestRate( ) : double +setAnnualInterestRate(newRate : double) : void +getDateCreated( ) : Date +getMonthlyInterestRate( ) : double +getMonthlyInterest( ) : double +withdraw(amt : double) : void +deposit(amt : double) : void Design a class named Account that contains: ■ A private int data field named id for the account (default 0). ■ A private double data field named balance for the account (default 0). ■ A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. Make it static. ■ A private Date data field named dateCreated that stores the date when the account was created. (private Date dateCreated)…arrow_forward
- Urgent Quick Question Write an equals method for the StepsFitnessTracker class that tests whether the one object is equal to another object that is passed as an argument (Object otherObject). The Object superclass provides an equals method that tests if two object references are equal. Your new equals method should override the Object equals method, and should test the following: • Return true if the current (this) object, and otherObject are identical references (hint: you can use the == operator for this). • Returns false if otherObject is null. • Returns false if the current (this) object and otherObject have different classes (hint: you can use the getClass() method provided by the Object superclass, see the Java 8 API documentation for details). • Casts otherObject to a StepsFitnessTracker, and tests for equality of each instance variable1 , if the instance variables are the same the method should return true. Now write an equals method for the DistanceFitnessTracker and…arrow_forwardUrgent Quick Question Write an equals method for the StepsFitnessTracker class that tests whether the one object is equal to another object that is passed as an argument (Object otherObject). The Object superclass provides an equals method that tests if two object references are equal. Your new equals method should override the Object equals method, and should test the following: • Return true if the current (this) object, and otherObject are identical references (hint: you can use the == operator for this). • Returns false if otherObject is null. • Returns false if the current (this) object and otherObject have different classes (hint: you can use the getClass() method provided by the Object superclass, see the Java 8 API documentation for details). • Casts otherObject to a StepsFitnessTracker, and tests for equality of each instance variable1 , if the instance variables are the same the method should return true. 1 To test for equality of each instance variable, you might want to…arrow_forwardProblem (Cylinder.java) a. Implement a class called Cylinder. A cylinder has a circle and one additional data member for representing the height (type float). b. Create appropriate constructors for your Cylinder class. c. Encapsulate it. d. Include methods for finding the volume and area of your Cylinder. area = 2 * (area of the circle in this cylinder) + 2 * pi * radius * height volume = (area of the circle in this cylinder) * height e. Override the toString method of the Object class. Try to use the toString of the Circle class and then just concatenate the remaining values. f. Override the equals method of the Object class. Two Cylinder objects are equal if they have the same center and the same radius and the same height. For example:arrow_forward
- Language is Java Write a Clothing class with the following attributes: color (e.g., "blue", "green", "orange") displayName (e.g., "Doctor Who hoodie", "slacks") price (e.g., 19.99, 7) Include only one constructor. It should have parameters for each of the attributes and set their values. Additionally, include getters and setters for each of the attributes. Add a driver, name it Purchases, and create 2 Clothing objects. Finally, print out some information about both objects (i.e., print the information from some or all of the getters). For example, if you created a Clothing object whose color was blue, whose display name was work trousers, for a price of 27.99, you could use the getters to print something like this:These work trousers are blue and cost $27.99.Don't hardcode the print statement for full credit, you must use the gettersarrow_forwardThis program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class to contain a new attribute. item_description (string) - Set to "none" in default constructorImplement the following method for the ItemToPurchase class. print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter. Ex. of print_item_description() output: Bottled Water: Deer Park, 12 oz. (2) Build the ShoppingCart class with the following data attributes and related methods. Note: Some can be method stubs (empty methods) initially, to be completed in later steps. Parameterized constructor which takes the customer name and date as parameters Attributescustomer_name (string) - Initialized in default constructor to "none"current_date (string) - Initialized in default constructor to "January 1, 2016"cart_items (list)Methodsadd_item()Adds an item to cart_items list. Has a parameter of…arrow_forwardThis program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class to contain a new attribute. item_description (string) - Set to "none" in default constructorImplement the following method for the ItemToPurchase class. print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter. Ex. of print_item_description() output: Bottled Water: Deer Park, 12 oz. (2) Build the ShoppingCart class with the following data attributes and related methods. Note: Some can be method stubs (empty methods) initially, to be completed in later steps. Parameterized constructor which takes the customer name and date as parameters Attributescustomer_name (string) - Initialized in default constructor to "none"current_date (string) - Initialized in default constructor to "January 1, 2016"cart_items (list)Methodsadd_item()Adds an item to cart_items list. Has a parameter of…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