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

  Modify the program in 6a so that, in addition to the cents

Modify the program in 6a so that, in addition to the cents, the user enters the denomination of the coin to which to convert the pennies, such as 5 for nickles or 25 for quarters.

  Write a program in c++ to accept a string

Write a program in C++ to accept a String and print the total no of vowels in it. Also print the string in upper and lower case

  Create a figure command interface with one method

Other objects can traverse an Array List by invoking the list's iterator method, which returns an Iterator. Such an Iterator is used quite a few times.

  Problem related to stroing of text file values into vector

I have to store the text file values into a vector and do the sum, here the text file sample: Expenses: Equipment:$300 Food: $50  Consumable expenses: $100

  Create two new arrays to hold the results of calculations

Create two new arrays to hold the results of calculations. Result array one is to hold the Euclidean distance between each point and the next point in the row.

  Write your own version of wc

Write your own version of wc. Your program is to receive a text file as a command line argument and then count and display the number of lines and characters in that text file.

  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.

  Write a program that uses a function that takes as arguments

Write a program that uses a function that takes as arguments a reference to Candy Bar, a pointer-to-char, a double, and an int and uses the last three values.

  What is encapsulation?

What is encapsulation? Why encapsulate in object oriented development?

  Need to convert this c code to mips

You need to convert this C code to MIPS - The subsequent is a sample output (user input is 2): Enter an integer: 2 The count of the integers that are greater than 2 is: 3 You have to assure the requirements specific in the instruction.

  Design a web page displaying list of hyperlinks

Write HTML code to design a web page displaying list of hyperlinks. Divide the browser screen into two frames. The frame on the left will be an image. The frame on the right will be a menu consisting of hyperlinks.

  Which is not a valid name for a method or function

Which is not a valid name for a method or function? Which of the following is a valid overloaded version of this method

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