Week 6. The first chapter talks about the use of multiple constructers,
which allow for a new object to be created in different ways (i.e. different type
of parameters). In the same way, methods can also have multiple versions.
Although each method has to have different parameters, otherwise the two
methods cannot be distinguished.
The following few chapters are about how objects are handled
in java. Objects are at the ‘end of a wire’ and when a new variable is assigned
to reference of the object, then any action taken on the new variable will also
affect the object (i.e. multiple ‘wires’ to the same object).
In exercise 92, a class called ‘Mydate’ has to implement the
method of finding the difference in years between two dates (to make it simple,
all months have 30 days). What I found difficult about this exercise was when
there was 364 days difference, which is technically still less than a year.
My solution to this problem, made easier by only having 30
day months, was to calculate the total number of days in a particular date. For
example, 10.10.2016 would equate to 725,680 total days. I then found the difference
of the two dates, and then took away 360 for each year.