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
¿Cómo es la onda percibida por un osciloscopio cuando hablamos de sonido? ¿Qué parámetros podemos observar en ella?
frozen [14]

Answer:

Las ondas de sonido, que es una onda longitudinal, son producidas por la vibración de un objeto de tal manera que (la onda de sonido requiere un medio de viaje, líquido sólido o gas) la dirección del sonido es la misma que la dirección de la vibración y como la el ancho de la vibración (hacia adelante y hacia atrás) aumenta, la amplitud de la vibración aumenta y el sonido es más fuerte

Un micrófono conectado al osciloscopio recoge el medio de aire vibrante de la onda de sonido de la energía de la onda de sonido y lo convierte (produce) señales eléctricas y electrónicas. El osciloscopio, que está diseñado para mostrar señales electrónicas, muestra las señales electrónicas transmitidas por el micrófono en la pantalla con los mismos valores de amplitud y frecuencia que el volumen y el tono de la onda de sonido, respectivamente.

Las características observables son;

1) El volumen o el volumen de la onda de sonido que se muestra como la amplitud) en el cátodo, con una amplitud más alta que representa un sonido más fuerte

2) El tono de la onda de sonido se muestra como el espaciado de onda en el osciloscopio, el sonido de tono más alto se muestra por las ondas que se acercan en la pantalla

Explanation:

7 0
3 years ago
People who enjoy working with their hands might enjoy a career as an
Kaylis [27]
People that enjoy working with their hands might enjoy being a construction worker but their are a lot of other jobs that involve using their hands but being a construction worker takes a lot of effort and a lot of hard work to complete.
6 0
3 years ago
Read 2 more answers
In web developing, what are the differences between front-end developer, back-end developer and full stuck developer?
Ilia_Sergeevich [38]

When it comes to front end, back end and full stack developer, the difference is determined by :

front end (the visible parts of a website)

back end (the “under the hood” databases and infrastructure)

full stack (a hybrid of both)

And front end developers work on technologies that are used to build front end(which is what clients visiting that website see)of application like HTML,CSS, Javascript ( Node js, Angular are also now used ).

Similarly back end developers work on back end technologies like Node js.

Full stack developers work on both front end and back end developers and know  both end technologies as well.

For example :

MEAN Stack developer where

M stands for Mongoose ( Back end database technology )

E stands for Express ( Back end technology)

A stands for angular ( front end technology)

N stands for Node ( back end technology)

8 0
3 years ago
Consider a class called Rocket that has a private instance variable called Engine. You are writing a "getter" for the Engine. Us
dusya [7]

Answer:

when user wants duplicate copy of the object

Explanation:

Encapsulation are one of the key foundations of object-oriented programming (OOP). It involves the bundling of data or information with the methods and various techniques which operate on that data.

It can be used in hiding the true values or state of a structured data object that is in a class, preventing unauthorized parties' direct access to them.

The circumstances that can be allowed in returning a reference to the existing Engine is when user wants duplicate copy of the object.

4 0
3 years ago
How to solve this?<br> In c++
andrey2020 [161]

Explanation:

6* 49 because you multiply the number of dots in the first figure by 49

8 0
3 years ago
Other questions:
  • A search engine that crawls uses
    7·1 answer
  • The Cursor is blinking in a white area on the Screen. This area where text will appear in the ____.
    10·2 answers
  • Briley has all the hardware she needs to construct a fully functional personal computer. She connects the various components and
    7·1 answer
  • What does cmyk stand for?
    5·2 answers
  • g A sign of thrashing is Group of answer choices the CPU utilization increases as the degree of multiprogramming is increased. t
    5·1 answer
  • I make a budget of my 1st Gamer PC its good?
    9·1 answer
  • In Excel, you can sort a table by one or more columns by.
    7·1 answer
  • 14. For the declaration, int a[4] = {1, 2, 3};, which one is right in the following description-
    12·1 answer
  • JUST NEED TO KNOW WHO ALL DOSE EDGINUITY
    12·2 answers
  • We can create tables in MS. Word from *<br> 2 points<br> Insert Tab<br> Home Tab<br> Mailings Tab
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!