• 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
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 62809
203
  • 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.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!