> Inexperienced Java programming user here, need urgent help?

Inexperienced Java programming user here, need urgent help?

Posted at: 2014-12-18 
Hi guys, inexperienced Java user here. We are currently being taught to use polymorphism and inheritance in our programmes.

We have been asked to create a programme which allows the user to calulcate the boundary length and area of a shape, they have to choose between a square, triangle or circle. After the user inputs which shape they wish to use, and the number of the side they wish to use the programme calulcates this and produces an output of both answers. Currently I have my main class shapeCalc, square, circle, triangle and MyShape (this is the class to use polymorphism. Could anyone explain how polymorphism works?

Polymorphism allows you to define many methods with the same name but different signatures. By signature, I mean the return type, parameter list of the method. To calculate area of square, you could define a method like,

float area(float side);

For rectangle, it would look like,

float area(float l, float b);

I leave the body of the method upto you to define. Polymorphism is more than method overloading (what we just did here is called over-loading(a name of method)).

Anything specific?