-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[+] Add EntryFactory to create entry and fix some problems.
- Loading branch information
Showing
5 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package billgates; | ||
|
||
import billgates.entities.Entry; | ||
import billgates.entities.EntryFactory; | ||
|
||
import java.time.ZonedDateTime; | ||
|
||
public class Main { | ||
|
||
public static void main(String[] args) { | ||
Entry entry = new EntryFactory(1) | ||
.setDate(ZonedDateTime.now()) | ||
.setValue(123) | ||
.setCurrency("CAD") | ||
.setDescription("RAY") | ||
.setFrom("Scott's credit card") | ||
.setTo("T&T supermarket") | ||
.createEntry(); | ||
System.out.println(entry); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package billgates.entities; | ||
|
||
import java.time.ZonedDateTime; | ||
|
||
public class EntryFactory { | ||
|
||
private int id = -1; | ||
private ZonedDateTime date = ZonedDateTime.now(); | ||
private double value = 0.0; | ||
private String currency = ""; | ||
private String description = ""; | ||
private String from = ""; | ||
private String to = ""; | ||
private String location = ""; | ||
|
||
// TODO splitter | ||
|
||
// TODO for splitter, payee | ||
|
||
public EntryFactory(int id) { | ||
this.id = id; | ||
} | ||
|
||
public Entry createEntry() { | ||
return new Entry( | ||
new Attribute<>(this.id, "id"), | ||
new Attribute<>(this.date, "date"), | ||
new Attribute<>(this.value, "value"), | ||
new Attribute<>(this.currency, "currency"), | ||
new Attribute<>(this.description, "description"), | ||
new Attribute<>(this.from, "from"), | ||
new Attribute<>(this.to, "to"), | ||
new Attribute<>(this.location, "location") | ||
); | ||
} | ||
|
||
public EntryFactory setDate(ZonedDateTime date) { | ||
this.date = date; | ||
return this; | ||
} | ||
|
||
public EntryFactory setValue(double value) { | ||
this.value = value; | ||
return this; | ||
} | ||
|
||
public EntryFactory setCurrency(String currency) { | ||
this.currency = currency; | ||
return this; | ||
} | ||
|
||
public EntryFactory setDescription(String description) { | ||
this.description = description; | ||
return this; | ||
} | ||
|
||
public EntryFactory setFrom(String from) { | ||
this.from = from; | ||
return this; | ||
} | ||
|
||
public EntryFactory setTo(String to) { | ||
this.to = to; | ||
return this; | ||
} | ||
|
||
public EntryFactory setLocation(String location) { | ||
this.location = location; | ||
return this; | ||
} | ||
} |