1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
storchak [24]
3 years ago
14

Create a Quadrilateral, Oval, Triangle, Polygon class that are all extended from an abstract Shape class (given below). Then ext

end the Quadrilateral class to make a Rectangle class and then extend the Rectangle class to make a Square class. Extend the Oval class to make a Circle class. Extend the Polygon to make a Pentagon and Hexagon classes. These shape classes will contain state information for the object to be drawn.
Computers and Technology
1 answer:
Lostsunrise [7]3 years ago
8 0

Answer:

Shapes.java

public abstract class Shapes {

}

Triangle.java

public abstract class Triangle extends Shapes {

}

IsoscelesTriangle.java

public class IsoscelesTriangle extends Triangle {

double side1;

double side2;

public double getSide1() {

return side1;

}

public void setSide1(double side1) {

this.side1 = side1;

}

public double getSide2() {

return side2;

}

public void setSide2(double side2) {

this.side2 = side2;

}

public IsoscelesTriangle(double side1, double side2) {

super();

this.side1 = side1;

this.side2 = side2;

}

public double perimeter()

{

return 2*side1+side2;

}

public double area()

{

return side1*side2/2;

}

}

EquilateralTriangle.java

public class EquilateralTriangle extends Triangle {

double side;

public EquilateralTriangle(double side) {

super();

this.side = side;

}

public double getSide() {

return side;

}

public void setSide(double side) {

this.side = side;

}

public double perimeter()

{

return 3*side;

}

public double area()

{

return 1.73205*side*side/4;

}

}

Quadrilateral.java

public abstract class Quadrilateral extends Shapes {

}

Rectangle.java

public class Rectangle extends Quadrilateral {

double length;

double breadth;

public double getLength() {

return length;

}

public void setLength(double length) {

this.length = length;

}

public double getBreadth() {

return breadth;

}

public void setBreadth(double breadth) {

this.breadth = breadth;

}

public Rectangle(double length, double breadth) {

super();

this.length = length;

this.breadth = breadth;

}

public double perimeter()

{

return 2*(length+breadth);

}

public double area()

{

return length*breadth;

}

}

Square.java

public class Square extends Quadrilateral {

double side;

public Square(double side) {

super();

this.side = side;

}

public double getSide() {

return side;

}

public void setSide(double side) {

this.side = side;

}

public double perimeter()

{

return 4*side;

}

public double area()

{

return side*side;

}

}

Rhombus.java

public class Rhombus extends Quadrilateral {

double length;

double breadth;

public Rhombus(double length, double breadth) {

super();

this.length = length;

this.breadth = breadth;

}

public double getLength() {

return length;

}

public void setLength(double length) {

this.length = length;

}

public double getBreadth() {

return breadth;

}

public void setBreadth(double breadth) {

this.breadth = breadth;

}

public double perimeter()

{

return 2*(length+breadth);

}

public double area()

{

return length*breadth/2;

}

}

Test.java

import java.util.Scanner;

public class Test {

public static void main(String[] args) {

// TODO Auto-generated method stub

Scanner sc=new Scanner(System.in);

System.out.println("Enter your choice");

System.out.println("1. Create IsoscelesTriangle ");

System.out.println("2. Create EquilateralTriangle");

System.out.println("3. Create Rectangle");

System.out.println("4. Create Square");

System.out.println("5. Create Rhombus");

System.out.println("6. Create Circle");

int choice=sc.nextInt();

switch(choice)

{

case 1:

System.out.println("Enter two sides of triangle");

double side1=sc.nextDouble();

double side2=sc.nextDouble();

IsoscelesTriangle isosceles=new IsoscelesTriangle(side1, side2);

System.out.println("Area of the triangle is "+isosceles.area());

System.out.println("Perimeter of the triangle is "+ isosceles.perimeter());

break;

case 2:

System.out.println("Enter side of the triangle");

double side=sc.nextDouble();

EquilateralTriangle equilateralTriangle=new EquilateralTriangle(side);

System.out.println("Area of the triangle is "+equilateralTriangle.area());

System.out.println("Perimeter of the triangle is "+ equilateralTriangle.perimeter());

break;

case 3:

System.out.println("Enter length and breadth");

double length=sc.nextDouble();

double breadth=sc.nextDouble();

Rectangle rectangle =new Rectangle(length, breadth);

System.out.println("Area of rectangle is "+rectangle.area());

System.out.println("Perimeter of the rectangle is "+rectangle.perimeter());

break;

case 4:

System.out.println("Enter side of the square");

double squareside=sc.nextDouble();

Square square=new Square(squareside);

System.out.println("area of the square is "+square.area());

System.out.println("Perimeter of the square is "+square.perimeter());

break;

case 5:

System.out.println("Enter length and breadth of rhombus");

double rlength=sc.nextDouble();

double rbreadth=sc.nextDouble();

Rhombus rhombus=new Rhombus(rlength, rbreadth);

System.out.println("area of the rhombus is "+rhombus.area());

System.out.println("Perimeter of the rhombus is "+rhombus.perimeter());

break;

case 6:

System.out.println("Enter radius of circle");

double radius=sc.nextDouble();

Circle circle=new Circle(radius);

System.out.println("area of the circle is "+circle.area());

System.out.println("Perimeter of the circle is "+circle.perimeter());

break;

}

}

}

You might be interested in
FOR DIGITAL DESIGN/ PHOTOGRAPHY
zysi [14]

Answer:

Its D DLSR and Mirrorless

Explanation:

Tell me if you get it wrong or right :3

6 0
3 years ago
Read 2 more answers
To create a chart, you need to select at least
Nitella [24]

To create a chart, you need to select at least two cells in a range of data.

two cells

<u>Explanation:</u>

In MS excel end user can create graph through insert menu and select chart. In MS excel end user should have enough data in each cells to generate graphs.  

In MS EXCEL end user can create bar graph, pie chart, and line graph. Normally graph means comparing either two sets of values or range of values.

If we select one value it is just graph which gives performance data.

Purpose of graph is to do analysis in graphical presentable manner which an organization can under visual rather than comparing values.

6 0
3 years ago
While moving into a new apartment, Titus needed to hold the door open with something heavy. It suddenly dawned on him that he co
tiny-mole [99]

Answer:probably and solution

Explanation:

7 0
3 years ago
Top/Bottom Rules allow a user to apply conditional formatting to cells that fall within the top or bottom numbers or percentile.
Aliun [14]

C. TRUST

Explanation:

7 0
3 years ago
Read 2 more answers
What is thesql command to list the total sales by customer , month , and product, with subtotals by customer and by month and a
alexira [117]

Answer:

The answer is below

Explanation:

The the sql command to list the total sales by customer , month , and product, with subtotals by customer and by month and a grand total for all product sales is:

SELECT S.CUS_CODE, T.TM_MONTH, S.P_CODE,

SUM(S.SALE_UNITS*S.SALE_PRICE) AS "TOTSALES"

FROM DWDAYSALESFACT AS S INNER JOIN DWTIME AS T ON S.TM_ID =

T.TM_ID

GROUP BY S.CUS_CODE,T.TM_MONTH,S.P_CODE WITH ROLLUP;

4 0
2 years ago
Other questions:
  • What is the full meaning of ICT
    14·2 answers
  • Susan bought a new sweater on sale for $28.93.she was charged HST of 13%.find the total amount of her bill including taxes.​
    9·1 answer
  • Write a method so that the main() code below can be replaced by the simpler code that calls method mphandminutestomiles(). origi
    14·2 answers
  • What three steps Name a group??
    14·1 answer
  • Once a graph has been created, you would need to start over to make any changes to it?
    5·1 answer
  • What are the four stages a customer goes through when buying a product?
    7·2 answers
  • Effective scrum masters apply which coaching behavior
    5·1 answer
  • What dd command would you use to copy the contents of a partition named /dev/drive1 to another partition, called /dev/backup?
    6·1 answer
  • What is media ethics. Explain two forms of maintaining media ethics with examples​
    13·1 answer
  • You are a developer for a news, entertainment, lifestyle, and fashion website. User traffic has steadily increased month-over-mo
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!