Questions about my program and Polymorphism
Posted
by
Strobe_
on Stack Overflow
See other posts from Stack Overflow
or by Strobe_
Published on 2013-10-22T21:38:10Z
Indexed on
2013/10/22
21:53 UTC
Read the original article
Hit count: 224
java
|polymorphism
Ok, so basically I'm creating a program which allows the user to select a shape (triangle, square, circle) and then it takes in a int and calculates the boundary length and area.
I have no problem doing this and have a program that's working perfectly. (https://gist.github.com/anonymous/c63a03c129560a7b7434 4 classes) But now I have to implement this with polymorphism concepts and I'm honestly struggling as to how to do it.
I have a basic idea of what I want to do when it comes to inheritance
Main
|
Shapes
/ | \
triangle circle square
But I don't understand how I'm supposed to override when all the methods within the triangle/square/circle classes are unique, there are no "abstract" methods as such that I could inherit from the "Shapes" class.
If somebody could make look quickly at the code I linked and suggest a way to do this it would be much appreciated.
Sorry if I was bad at explaining this. Thanks.
© Stack Overflow or respective owner