Skip to content

Commit 0ff138a

Browse files
msomjimirkoperillo
authored andcommitted
extract concepts from gigasecond example
1 parent 110501c commit 0ff138a

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Gigasecond
2+
3+
[Example implementation](https://github.com/exercism/java/blob/master/exercises/gigasecond/.meta/src/reference/java/Gigasecond.java)
4+
5+
## General
6+
7+
- Imports: placed at the top of the file allowing access to methods/classes implemented in other files.
8+
9+
- Integers: Integer is a wrapper class around the primitive type `int` which contains a single field of type `int`. The difference between an `int` and an `Integer` is that `int` can only be a binary value of an integer whereas an `Integer`, being a class, has access to a number of other inbuilt functions making it more flexible to manipulation.
10+
11+
- Classes: The tested method is defined in a class
12+
13+
- Visibility: By default methods in a class can be accessed by other classes within the same package. Other options are `protected`, `private`, or `public`
14+
15+
- Assignment: assigning values, in this case, the private property that contains the date
16+
17+
- Properties: In object oriented programming classes tend to have state, such state is maintained within properties to be set/read at a later time during runtime
18+
19+
- Overloading constructors: Sometimes there can be multiple ways to initialize a class, this is known as overloading since the name of the methods match the name of the class but only vary by their arguments.
20+
21+
- Scoping: `{` and `}` used to identify scope of method
22+
23+
- Objects: creating an instance of the LocalDateTime
24+
25+
- Dates: object containing information about date
26+
27+
- Times: object containing information about the time on a specific date
28+
29+
- Methods: used as a way to interact with the class
30+
31+
- Return values: returning values from a method, deonted by `return` in the method and typed in the method signature
32+
33+
## Approach: Overloading Constructors
34+
- Two constructors where one that takes a LocalDate object as an argument and when initialized, converts it to a LocalDateTime and another that just takes the LocalDateTime object and sets that as a property in the instance of the class.
35+
- method that returns the time (`getDateTime`) adds a gigasecond to the time initialized before returning the new LocalDateTime object

0 commit comments

Comments
 (0)