This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Need help asap XOXO  RSS feed

 
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

 
Java Cowboy
Posts: 16084
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.
 
Marshal
Posts: 61713
193
  • 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.
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!