This week's giveaway is in the Spring forum. We're giving away four copies of liveProject: Protecting User Data with Spring Security and OAuth2 and have Laurentiu Spilca on-line! See this thread for details.
Now Coordinate extends Pair.
Constructor now use values t and s.
Created an own exception class, because this is asked in assignment. Indeed is NullPointerException also possible.
The assignment asks to implement Coordinate as Pair, so guess inheritance.
Indeed, my fault about generic types twice.
There is nothing written in the assignment about two generic types.
Changed getDistanceFromOrigin(), but doesn't work. Method hypot() gave problems indeed. What did I do wrong?
Thanks so far.
My home work so far now. Now I must implement a generic class Coordinate as Pair of two numeric (subtype of Number) values. The getDistanceFromOrigin method returns the distance from the coordinate to the origin.
I get stuck with the Coordinate class, what did I do wrong?
Thanks for additional suggestions.
Hope I can make it more clear.
With class Book I can create a new book, for example "Java Development".
Within class BookCopy there must be two constructors.
First constructor is to create a new BookCopy with a book as parameter.
Second constructor is to create a copy of a BookCopy with a bookcopy as parameter.
If it is not clear, please let me know how I can make it more clear.
Didn't get any errors. But b2 and b3 both refer to the same object, but they must be different objects. For example: I have a book, named "Java Development" in the library and the library has 10 BookCopies of "Java Development". So I need to change public BookCopy(BookCopy bookcopy), so it will make a new object without referring to the same object.
Because in the assignment, MyClass2 goes to west and MyClass1 goes to east, that's why there's an if (array[i] != null) needed with additional code which is not implemented in this snippet to keep the code simple in this post.