Design a class named triangle that extends geometry

Assignment Help C/C++ Programming
Reference no: EM132096038

PLEASE!! Any Help would be great

1. Design an interface named Colorable with a void method named howToColor().

2. Design a class named Geometry that implements the Comparable interface. The class contains:

a. Two integer data fields named GeometricId and numOfSides. GeometricId, initialized to 1, specifies the unique identifier whose value is automatically assigned to every instance of Geometric class by its constructors; numOfSides specifies the number of sides of an instance of a Geometric class;

b. A string field named color that stores the color of the Geometric object;

c. A no-arg constructor that creates a Geometric object with a unique GeometricId;

d. A constructor that creates a Geometric object with specified color and number of sides. The constructor should also assign a unique identifier to GeometricId field;

e. Implements compareTo method based on the number of sides. (Note: you are allowed to add extra fields or methods if necessary)

3. Design a class named Square that extends Geometry and implements the Colorable interface. The class contains: a.

A constructor that creates a Square object with the specified color and sets the numOfSides field to 4.

b. Print the number of sides and color in howToColor() method.

c. Override toString() method to display all the data fields, including the superclass's field) of the Square

4. Design a class named Triangle that extends Geometry and implements the Colorable interface. The class contains: a.

A constructor that creates a Traingle object with the specified color and sets the numOfSides field to

b. Print the number of sides and color in howToColor() method.

c. Override toString() method to display all the data fields, including the superclass's field) of the Triangle.

5. Design a class named Test that contains the following methods:

a. A static void Generic method displayGeometricObject that reads a generic array, named inputArray, of objects and does the following for every object in the array:

a. If the object at a particular index in inputArray is Square, the method displays the square properties defined in toString method and also calls the howToColor() method.

b. If the object at a particular index in inputArray is Triangle, the method displays the Triangle properties defined in toString method and also calls the howToColor() method.

b. Copy the following main method:

public static void main(String[] args) {

Geometry[] inputArray = new Geometry[3];

inputArray[0] = new Square("red");

inputArray[1] = new Triangle("yellow");

inputArray[2] = new Square("green");

displayGeometricObject(inputArray);

java.util.Arrays.sort(inputArray);

System.out.println("Geometric objects in the increasing order of their number of sides");

displayGeometricObject(inputArray); }

Sample Output: Square: ID: 1 Number of sides: 4 Color: red Print all the 4 sides with color: red Triangle:

ID: 2 Number of sides: 3 Color: yellow Print all the 3 sides of Triangle with color: yellow Square:

ID: 3 Number of sides: 4 Color: green Print all the 4 sides with color: green Geometric objects in the increasing order of their number of sides Triangle:

ID: 2 Number of sides: 3 Color: yellow Print all the 3 sides of Triangle with color: yellow Square:

ID: 1 Number of sides: 4 Color: red Print all the 4 sides with color: red Square:

ID: 3 Number of sides: 4 Color: green Print all the 4 sides with color: green

Reference no: EM132096038

Questions Cloud

Find the skyline position of the n buildings in the form : Give the information of n buildings (L,R,H) which are the left position, right position, and the height of the building, respectively.
Discuss the application of wireless technologies : Discuss the application of wireless technologies in a field which you find most interesting (i.e. healthcare, home automation, transportation).
Write a function that orders an array of items : Write the function so that it can order an array of arbitrary items by passing a not only the array.
Confidence interval and compare results : Find a 95% confidence interval for the mean price of all textbooks. Then find a 99% confidence interval and compare your results.
Design a class named triangle that extends geometry : Design a class named Triangle that extends Geometry and implements the Colorable interface.
Linear relation among air temperature : How do I determine if there is a linear relation among air temperature x1?, wind speed x2?, and wind chill y from the data shown below
Determine the? p-value of hypothesis test : The data below represents the population of a certain country every 10 years for the years? 1900-2000. How do I determine the? least-squares regression?
Develop a web-based pothole tracking and repair system : Why is it that many software developers don't pay enough attention to requirements engineering? Are there ever circumstances where you can skip it?
Develop a method with java program : Develop a method with java program. Write a main method to test your method.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd