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
astraxan [27]
3 years ago
4

Write an inheritance hierarchy of three-dimensional shapes. Make a toplevel shape interface that has methods for getting informa

tion such as the volume and surface area of a three-dimensional shape. Then make classes and subclasses that implement various shapes such as cubes, rectangular prisms, spheres, triangular prisms, cones, and cylinders. Place common behavior in superclasses whenever possible, and use abstract classes as appropriate. Add methods to the subclasses to represent the unique behavior of each three-dimensional shape, such as a method to get a sphere's radius.
Computers and Technology
1 answer:
kirill [66]3 years ago
7 0

Answer:

Check the explanation

Explanation:

Test.java

import javax.swing.*;

public class Test {

  public static void main( String args[] )

  {

     Point point = new Point( 7, 11 );        

     Square square = new Square( 3.5, 22, 8 );

     Cube cube = new Cube( 3.3, 10, 10 );

Shape[] arrayOfShapes = new Shape[ 3 ];

     String result = "";

arrayOfShapes[ 0 ] = point;

     arrayOfShapes[ 1 ] = square;

     arrayOfShapes[ 2 ] = cube;

result += point.getName() + ": " +

                   point.toString();

result += "\n" + square.getName() + ": " +

                   square.toString();

result += "\n" + cube.getName() + ": " +

                   cube.toString();

for ( int i = 0; i < 3; i++ ) {

        result += "\n" + arrayOfShapes[ i ].getName() +

           ": " + arrayOfShapes[ i ].toString();

         result += "\n" + "Area = " +

           arrayOfShapes[ i ].area();

        result += "\n" + "Volume = " +

           arrayOfShapes[ i ].volume();

     }

JOptionPane.showMessageDialog(

           null, result, "Shapes",

           JOptionPane.INFORMATION_MESSAGE );  

     System.exit( 0 );

  }

}  

Point.java

public class Point extends Shape {

  protected double x, y;

public Point( double a, double b ) { setPoint( a, b ); }

public void setPoint( double a, double b )

  {

     x = a;

     y = b;

  }

public double getX() { return x; }

public double getY() { return y; }

public String toString()

     { return "[" + x + ", " + y + "]"; }

public String getName() { return "Point"; }

}

Square.java

public class Square extends Point {

  protected double side;

public Square()

     { this( 0.0, 0.0, 0.0 ); }

public Square( double s, double a, double b )

  {

     super( a, b );

     setSide( s );

  }

public void setSide( double s )

     { side = ( s >= 0 ? s : 0 ); }

public double getSide() { return side; }

public double area() { return Math.pow( side, 2 ); }

public String toString()

     { return "Corner = " + super.toString() +

              "; side = " + side; }

public String getName() { return "Square"; }

}

Cube.java

public class Cube extends Square {

  private double depth;

public Cube( double s, double a, double b )

  {

     super( s, a, b );

     depth = s;

}

public double area() { return super.area() * 6; }

public double volume() { return super.area() * depth; }

public String toString()

     { return super.toString() + "; depth = " + depth; }

public String getName() { return "Cube"; }

}

Shape.java

public abstract class Shape {

  public double area() { return 0.0; }

  public double volume() { return 0.0; }

  public abstract String getName();  

}

You might be interested in
you are using linux and need to perform a reverse lookup of the ip address 10.0.0.3. which command would you use to accomplish t
ollegr [7]

A command you would use to perform a reverse lookup of the IP address 10.0.0.3 on a Linux system: dig -x 10.0.0.3.

<h3>What is a Linux command?</h3>

A Linux command can be defined as a software program that is designed and developed to run on the command line, in order to enable an administrator (end user) of a Linux network perform both basic and advanced tasks by only entering a line of text.

<h3>What is IP address?</h3>

IP address is an abbreviation for Internet protocol address and it can be defined as a unique set of numbers that are assigned to a computer, website or other network devices, in order to successfully differentiate them from one another in an active network system.

In Computer Networking, a command which an administrator (end user) would use to perform a reverse lookup of the IP address 10.0.0.3 on a Linux system is dig -x 10.0.0.3.

Read more on Linux commands here: brainly.com/question/25480553

#SPJ1

3 0
2 years ago
Need help with python coding
Ivanshal [37]

Answer:

def= definition

Explanation:

7 0
3 years ago
Read 2 more answers
Open punctuation means that no punctuation follows the salutation or complimentary close. *
zloy xaker [14]

Answer:

True

Explanation:

When open punctuation is used, we do not expect the use of punctuation after salutation or complimentary close. It is a relatively new concept in business writing and we can rightly use this method in modified block letter style of writing.  

Some companies have developed business letter templates that are arranged in an open style, which permits the use of open punctuation in all aspect of business writings.  

7 0
3 years ago
Which one of the following items is an example of software?
Harlamova29_29 [7]
Word processing program is an example of a software. All the others, such as Printer, Keyboard and Mouse are examples of Computer peripheral devices or in short hardware devices. Generally these listed hardware devices come under input or output computer device category. Also, by classic meaning in layman terms these hardware components can be touched or felt. In contrast, a word processing program is a part of a computer system that consists of data or computing instructions and provides the mechanism to computer to perform a certain task utilizing it's hardware resources. Such components of computer system which are written using one of the computer languages are called computer software or software programs or simply software.
4 0
3 years ago
What is the function of tab?<br>​
Sholpan [36]

Answer:

The function of the tab is used to advance the cursor to the next tab key.

5 0
1 year ago
Other questions:
  • Fibre channel switched networks rely on the concept of a ___________________which is a fundamental concept in how the network wo
    10·1 answer
  • 4. When determining the tone of their tweets, marketers should consider
    8·1 answer
  • 5. Why are female fans particularly valuable to the sports industry? Cite two<br> specific reasons.
    11·1 answer
  • An _____image is an image that appears on a web page
    8·1 answer
  • Computer programs and games are called what?
    13·1 answer
  • Adobe gives away the Acrobat Reader to build a market for the sale of software that creates Acrobat files. This is an example of
    5·1 answer
  • Q.drtrdyudoijoemrkdf
    6·2 answers
  • Not all output display data for humans to read explain why​
    13·1 answer
  • WILL GIVE BRAINLIST Which statements accurately describe electronic tools? Check all that apply. Electronic tools collect large
    12·1 answer
  • The int function can convert floating-point values to integers, and it performs rounding up/down as needed.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!