• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help asap XOXO  RSS feed

 
Tiffany Watson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, I'm fairly new to Java and I was wondering if I can get a hand with something.
My teacher gave me this instructions and I was supposed to pass this activity it right now.
Any help will be much appreciated. Thanks guys!
Problem:


Quadrilaterals can be a Parallelogram, Square, Rectangle, Trapezoid and Rhombus. Area and perimeter can computed from all quadrilaterals.


Create and program the inheritance tree of the shapes given above. Make sure that common attributes and methods are declared in the super class.


Create a public test class that instantiates all sub classes of Quadrilateral. Demonstrate the use of each object by setting necessary attributes in order for you to compute area and perimeter. In the test class, create a method called showDetails() that accepts a Quadrilateral reference. This method should show the area and perimeter and other specific information of the instance passed thru the argument.

Special instruction:


ONLY USE ONE JAVA FILE and name it LE6_Surname.java.


Sample Output:


SQUARE
Side: 4.0
Area: 16.0
Perimeter: 16.0

RECTANGLE
Length: 4.0
Width: 2.0
Area: 8.0
Perimeter: 12.0

RHOMBUS
Side: 2.0
Diagonal 1 (p): 2.0
Diagonal 2 (q): 2.0
Area: 2.0
Perimeter: 8.0

TRAPEZOID
Side a: 6.0
Side b (base): 8.0
Side c: 2.0
Side d: 2.0
Height: 1.0
Area: 7.0
Perimeter: 18.0

PARALLELOGRAM
Side a: 5.0
Side b (base): 6.0
Height: 4.0
Area: 24.0
Perimeter: 22.0

 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Please explain us how far you've come, and what specifically you need help with.

You'll have to create a class Quadrilateral, and subclasses for the specific kinds of shapes, as the assignment says. Did you manage to do that?

Since you'll have to put everything in one source file named LE6_Watson.java, you'll have to create a public class named LE6_Watson in that file - that will be the public test class that the assignment mentions. It will have to have a public static void main(String[] args) method, and a showDetails() method as the assignment explains.
 
Campbell Ritchie
Marshal
Posts: 56522
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome agan

There are various words we never use. ASAP is one of them.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!