samedi 19 avril 2014

Dealing with interfaces and inheritance


Vote count:

0




So I've tried searching only and for videos to help me out but the concept of dealing with interfaces (more specifically, when including inheritance from a superclass) is still very confusing to me. For example, let's say I've made a program that had its various methods but would take waypoints and calculate the distance between them arithmetically (using the Pythagorean Theorem) within the main() method. It's compiled and runs without any issues.


Now, I want to go back to that program but now I want to try extending Point2D.Double and using an interface we'll call Buddy. Within Buddy, I have:



public double toDistance(Buddy littleBuddy);
public Point2D.Double getPoint();
public Point2D.Double getPoint(Buddy littleBuddy);


Can you explain to me how to:


a) use Point2D.Double to do my arithmetic calculation for me (I think it has the formula already, doesn't it?)


b) write the proper syntax for getting the result from the calculation and using it when needed.


I have a small grasp of the concept of each separately, but bringing the two together is throwing me way off.



asked 2 mins ago






Aucun commentaire:

Enregistrer un commentaire