Skip to content

Commit 8f258fc

Browse files
committed
# Conflicts: # src/main/java/command/Process.java
2 parents 5eeb023 + 8394b80 commit 8f258fc

File tree

8 files changed

+463
-437
lines changed

8 files changed

+463
-437
lines changed

data/duke.txt

323 Bytes
Binary file not shown.

src/main/java/command/Instruction.java

+4
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,8 @@ public boolean isDeletePayee(String input) {
7575
public boolean isgetpayee(String input) {
7676
return input.startsWith("getpayee");
7777
}
78+
79+
public boolean isInvoice(String input) {
80+
return input.startsWith("invoice");
81+
}
7882
}

src/main/java/command/Parser.java

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public static boolean parse(String input, TaskList tasklist, Ui ui,
8888
process.addPayee(input, managermap, ui);
8989
} else if (instr.isDeletePayee(input)) {
9090
process.deletePayee(input, managermap, ui);
91+
} else if (instr.isInvoice(input)) {
92+
process.inVoice(input, tasklist, ui);
9193
} else {
9294
throw new AlphaNUSException(" ☹ OOPS!!! I'm sorry, but I don't know what that means :-(");
9395
}

src/main/java/command/Process.java

+409-390
Large diffs are not rendered by default.

src/main/java/task/Deadline.java

+8-28
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,22 @@ public class Deadline extends Task implements Serializable {
1616
/**
1717
* Creates a Deadline instance and initialises the required attributes.
1818
* @param description Description of the deadline.
19-
* @param by Deadline of the task in format "dd/MM/yyyy HHmm".
2019
*/
21-
public Deadline(String description, String by) {
20+
public Deadline(String description) {
2221
super(description);
2322
this.by = null;
2423
this.type = "D";
25-
this.inVoice = false;
24+
this.inVoice = null;
25+
this.isInVoice = false;
2626
}
2727

2828
/**
2929
* set the value of inVoice as true.
3030
*/
31-
public void setInVoice() {
32-
this.inVoice = true;
33-
setBy(inVoice);
34-
}
35-
36-
/*
37-
public void setBy(boolean inVoice){
38-
if(inVoice==true){
39-
Date date = new Date(System.currentTimeMillis());
40-
java.util.Calendar calendar = java.util.Calendar.getInstance();
41-
calendar.setTime(date);
42-
calendar.add(Calendar.DAY_OF_MONTH,30);
43-
Date newDate = calendar.getTime();
44-
this.by = dataformat.format(newDate);
45-
}
46-
}
47-
*/
48-
49-
/**
50-
* return the boolean value (true or false) of the invoice.
51-
* @return the task's invoice value.
52-
*/
53-
public boolean getInVoice() {
54-
return inVoice;
31+
public void setInVoice(String inVoice) {
32+
this.isInVoice = true;
33+
setBy(isInVoice);
34+
this.inVoice = inVoice;
5535
}
5636

5737
/**
@@ -60,6 +40,6 @@ public boolean getInVoice() {
6040
*/
6141
@Override
6242
public String giveTask() {
63-
return "[D]" + super.giveTask() + "(by: " + by + ")";
43+
return "[D]" + super.giveTask() + "(by: " + by + ")" + " (invoice: " + inVoice + ")";
6444
}
6545
}

src/main/java/task/Task.java

+30-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public class Task implements Serializable {
1616
protected String at;
1717
protected String after;
1818
protected String period;
19-
protected Boolean inVoice;
19+
protected Boolean isInVoice;
20+
protected String inVoice;
2021

2122
private static SimpleDateFormat dataformat = new SimpleDateFormat("dd/MM/yyyy HHmm");
2223

@@ -42,7 +43,7 @@ public String giveTask() {
4243
* @return The status icon of the Task based on isDone.
4344
*/
4445
public String getStatusIcon() {
45-
return (isDone ? "✓" : "✘"); //return tick or X symbols
46+
return (isInVoice ? "✓" : "✘"); //return tick or X symbols
4647
}
4748

4849
/**
@@ -52,6 +53,15 @@ public void setDone() {
5253
this.isDone = true;
5354
}
5455

56+
/**
57+
* set the value of inVoice as true.
58+
*/
59+
public void setInVoice(String inVoice) {
60+
this.isInVoice = true;
61+
setBy(isInVoice);
62+
this.inVoice = inVoice;
63+
}
64+
5565
/**
5666
* Sets a new value to the by attribute.
5767
*/
@@ -115,9 +125,25 @@ public String getAt() {
115125

116126
/**
117127
* Gets the invoice status of the Task.
118-
* @return a boolean value invoice.
128+
* @return a boolean value isInvoice.
129+
*/
130+
public Boolean statusInVoice() {
131+
return this.isInVoice;
132+
}
133+
134+
/**
135+
* return the boolean value (true or false) of the invoice.
136+
* @return the task's invoice value.
137+
*/
138+
public boolean getIsInVoice() {
139+
return this.isInVoice;
140+
}
141+
142+
/**
143+
* Gets the invoice string of the Task.
144+
* @return a string represents invoice.
119145
*/
120-
public boolean getInVoice() {
146+
public String getInVoice() {
121147
return this.inVoice;
122148
}
123149
}

src/main/java/ui/Ui.java

+10
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ public void printAddPayeeMessage(String name, Payee payee, int payeesize) {
207207
System.out.print(line);
208208
}
209209

210+
/**
211+
* Prints message to indicate a deadline with an invoice added.
212+
* @param task Task to be edited.
213+
*/
214+
public void printAddInvoiceMessage(Task task) {
215+
System.out.print(line);
216+
System.out.println("\t" + "Got it. I've added invoice to this deadline:");
217+
System.out.print("\t" + task.giveTask() + "\n");
218+
}
219+
210220
/**
211221
* Prints message to indicate a Payment being deleted.
212222
* @param payee Payee containing identification information of Payee.

src/test/java/WithinPeriodTaskTest.java

-15
This file was deleted.

0 commit comments

Comments
 (0)