-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Lim Yu Long] ip #634
Open
yulonglim
wants to merge
51
commits into
nus-cs2103-AY2122S1:master
Choose a base branch
from
yulonglim:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,465
−44
Open
[Lim Yu Long] ip #634
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
d839859
Add Gradle support
eec5f1f
Level-1
yulonglim e5177f0
Level-1
yulonglim 6328329
Level-2
yulonglim df8688b
Level-3
yulonglim c66222c
Level-4
yulonglim 4e953c0
Level-4
yulonglim 9e177ea
Level-6
yulonglim c6600c4
Added options to save file + more OOP
yulonglim ec68756
Second week work
yulonglim bc9975c
Merge pull request #1 from yulonglim/branch-Level-7
yulonglim b220aca
Added gradle support
yulonglim e9865c3
Merge pull request #2 from yulonglim/add-gradle-support
yulonglim 1c62cc6
Added gui
yulonglim 501bae5
Update build.gradle
yulonglim 546cdf1
Merge branch 'master' into branch-Level-10
yulonglim 30d2353
Merge pull request #3 from yulonglim/branch-Level-10
yulonglim 1567d4d
Update Controller.java
yulonglim 281f074
Updated readme
yulonglim 65ecfad
Merge pull request #4 from yulonglim/Use-GFMD
yulonglim 2f476f2
Update README.md
yulonglim 503fa60
Update README.md
yulonglim 1ad1526
Merge pull request #5 from yulonglim/Use-GFMD-1
yulonglim f46338a
Merge pull request #6 from yulonglim/Use-GFMD
yulonglim 864e258
Current find is case sensitive
yulonglim ead486c
Merge pull request #8 from yulonglim/A-Assertions
yulonglim f08b6f3
Current Code is not of high quality
yulonglim 08ca499
Merge pull request #9 from yulonglim/A-CodeQuality
yulonglim 0340b8a
Current Code does not allow for updating of task
yulonglim 1ba4022
Merge pull request #10 from yulonglim/C-update
yulonglim 0c5c99b
Current Code does not allow for updating of task
yulonglim 7e17e7f
Merge pull request #11 from yulonglim/C-update
yulonglim b5c99c3
Ui.png added
yulonglim 6dd13f2
Added User Guide
yulonglim db716a6
Updated UserGuide
yulonglim 3623e91
Improved code coverage for certain use case
yulonglim ea2de4a
Updated some method headers to reflect changes from 2103 bot
yulonglim 3f00b07
Updated code to be able to build and run at java 11
yulonglim 3121a7a
Current code requires users to press load at first run
yulonglim 6634b2a
Merge pull request #13 from yulonglim/A-UserGuide
yulonglim 121c99f
added inline text
yulonglim 297c3e9
Merge pull request #14 from yulonglim/Use-GFMD
yulonglim ddae27e
Current code had a small bug due to previous update which caused some…
yulonglim 38f6f32
Merge remote-tracking branch 'origin/master'
yulonglim 23edda1
Update Controller.java
yulonglim 770f309
DukeTest file was moved by accident during one of the updates and was…
yulonglim 96f960a
Merge remote-tracking branch 'origin/master'
yulonglim a57ae3a
TaskList.java does not have javadocs
yulonglim 3639cac
Storage load() method was too long and had parsing elements written in
yulonglim b022b4f
Cleaned up code
yulonglim c340be3
More abstraction done to make the code less nested given feedback fro…
yulonglim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added gui
commit 1c62cc6dc71ead5b6b14daadd0a3faebfa6d346d
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
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,147 @@ | ||
package duke; | ||
|
||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.DatePicker; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.TextField; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
|
||
|
||
public class Controller { | ||
|
||
private static Storage storage = new Storage("C:\\Users\\65906\\IdeaProjects\\ip\\duke.txt"); | ||
private static TaskList tasks; | ||
|
||
@FXML | ||
private Label listLabel; | ||
|
||
@FXML | ||
private Label deleteError; | ||
|
||
@FXML | ||
private TextField deleteText; | ||
|
||
@FXML | ||
private TextField taskType; | ||
|
||
@FXML | ||
private TextField taskDescription; | ||
|
||
@FXML | ||
private DatePicker taskDate; | ||
|
||
@FXML | ||
private Label addTaskError; | ||
|
||
@FXML | ||
private TextField doneText; | ||
|
||
@FXML | ||
private Label doneError; | ||
|
||
@FXML | ||
private TextField findText; | ||
|
||
public void load(ActionEvent a) { | ||
{ | ||
try { | ||
tasks = new TaskList(storage.load()); | ||
} catch (IOException | DukeException e) { | ||
tasks = new TaskList(); | ||
} | ||
String listContent = ""; | ||
for (int i = 0; i < tasks.size(); i++) { | ||
listContent += (i + 1) + ". " + tasks.getTask(i).toString() + "\n"; | ||
} | ||
listLabel.setText("Here are the tasks in your list:\n" + listContent); | ||
} | ||
} | ||
|
||
public void load() { | ||
String listContent = ""; | ||
for (int i = 0; i < tasks.size(); i++) { | ||
listContent += (i + 1) + ". " + tasks.getTask(i).toString() + "\n"; | ||
} | ||
listLabel.setText("Here are the tasks in your list:\n" + listContent); | ||
addTaskError.setText(""); | ||
deleteError.setText(""); | ||
doneError.setText(""); | ||
} | ||
|
||
public Task taskParse(String type, String description, String dateTime){ | ||
if (type.equalsIgnoreCase("T")) { | ||
return new Todo(description); | ||
} else if (type.equalsIgnoreCase("D")) { | ||
return new Deadline(description,dateTime); | ||
} else if (type.equalsIgnoreCase("E")) { | ||
return new Event(description,dateTime); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
public void add(ActionEvent a) { | ||
if (taskType.getText().equalsIgnoreCase("T")) { | ||
tasks.addTask(taskParse(taskType.getText(), taskDescription.getText(), "")); | ||
this.load(); | ||
} else if (taskType.getText().equalsIgnoreCase("D") || taskType.getText().equalsIgnoreCase( "E")) { | ||
tasks.addTask(taskParse(taskType.getText(), taskDescription.getText(), | ||
taskDate.getValue().toString())); | ||
this.load(); | ||
} else { | ||
addTaskError.setText("Wrong Format"); | ||
} | ||
|
||
} | ||
|
||
public void done(ActionEvent a) { | ||
try { | ||
int doneIndex = Integer.parseInt(doneText.getText()) - 1; | ||
if(doneIndex > tasks.size() - 1 || doneIndex < 0) { | ||
doneError.setText("Please enter a number in the list"); | ||
} else { | ||
tasks.markAsDone(doneIndex); | ||
this.load(); | ||
} | ||
} catch (NumberFormatException e) { | ||
doneError.setText("Please enter integer"); | ||
} | ||
} | ||
|
||
public void delete(ActionEvent a){ | ||
try { | ||
int deleteIndex = Integer.parseInt(deleteText.getText()) - 1; | ||
if(deleteIndex > tasks.size() - 1 || deleteIndex < 0) { | ||
deleteError.setText("Please enter a number in the list"); | ||
} else { | ||
tasks.removeTask(deleteIndex); | ||
|
||
this.load(); | ||
} | ||
} catch (NumberFormatException e) { | ||
deleteError.setText("Please enter integer"); | ||
} | ||
} | ||
|
||
public void find(ActionEvent a) { | ||
ArrayList<Task> result = new ArrayList<>(); | ||
String listContent = ""; | ||
|
||
for (int i = 0; i < tasks.size(); i++) { | ||
if (tasks.getTask(i).description.contains(findText.getText())) { | ||
result.add(tasks.getTask(i)); | ||
} | ||
} | ||
if (result.size() == 0) { | ||
listLabel.setText("There are no matching task in your list!\nPress load to go back!"); | ||
} else { | ||
for (int i = 0; i < result.size(); i++) { | ||
listContent += (i + 1) + ". " + result.get(i).toString() + "\n"; | ||
} | ||
listLabel.setText("Here are the matching tasks in your list:\n" + listContent + "Press load to go back!"); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main.java.duke; | ||
package duke; | ||
|
||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main.java.duke; | ||
package duke; | ||
|
||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
|
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,9 @@ | ||
package duke; | ||
|
||
import javafx.application.Application; | ||
|
||
public class Launcher { | ||
public static void main(String[] args) { | ||
Application.launch(Duke.class, args); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main.java.duke; | ||
package duke; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main.java.duke; | ||
package duke; | ||
|
||
/** | ||
* Task class used by the duke class | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main.java.duke; | ||
package duke; | ||
|
||
import java.util.ArrayList; | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main.java.duke; | ||
package duke; | ||
|
||
/** | ||
* class that extends task | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main.java.duke; | ||
package duke; | ||
|
||
/** | ||
* Class which stores basic output of the bot | ||
|
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,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.DatePicker?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.TextField?> | ||
<?import javafx.scene.layout.AnchorPane?> | ||
<?import javafx.scene.shape.Rectangle?> | ||
|
||
<AnchorPane prefHeight="518.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="duke.Controller"> | ||
<children> | ||
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#c8cacd" height="149.0" layoutX="2.0" layoutY="118.0" stroke="BLACK" strokeType="INSIDE" width="291.0" /> | ||
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#c8cacd" height="112.0" layoutX="2.0" layoutY="267.0" stroke="BLACK" strokeType="INSIDE" width="291.0" /> | ||
<Button layoutX="214.0" layoutY="298.0" mnemonicParsing="false" onAction="#delete" text="Delete" /> | ||
<Button layoutX="234.0" layoutY="209.0" mnemonicParsing="false" onAction="#add" text="Add" /> | ||
<Label fx:id="listLabel" alignment="TOP_CENTER" layoutX="293.0" layoutY="8.0" prefHeight="485.0" prefWidth="329.0" text="Press Load" /> | ||
<Button layoutX="300.0" layoutY="14.0" mnemonicParsing="false" onAction="#load" text="Load" /> | ||
<TextField fx:id="deleteText" layoutX="24.0" layoutY="295.0" /> | ||
<Label fx:id="deleteError" layoutX="23.0" layoutY="335.0" prefHeight="26.0" prefWidth="243.0" /> | ||
<TextField fx:id="taskType" layoutX="24.0" layoutY="148.0" /> | ||
<Label layoutX="24.0" layoutY="131.0" prefHeight="17.0" prefWidth="110.0" text="Add a Task" /> | ||
<Label layoutX="205.0" layoutY="152.0" prefHeight="17.0" prefWidth="85.0" text="Type (T,D,E)" /> | ||
<Label layoutX="203.0" layoutY="184.0" prefHeight="17.0" prefWidth="73.0" text="Description" /> | ||
<TextField fx:id="taskDescription" layoutX="24.0" layoutY="180.0" /> | ||
<DatePicker fx:id="taskDate" layoutX="23.0" layoutY="209.0" /> | ||
<Label layoutX="205.0" layoutY="213.0" prefHeight="17.0" prefWidth="42.0" text="Date" /> | ||
<Label fx:id="addTaskError" layoutX="23.0" layoutY="234.0" prefHeight="26.0" prefWidth="243.0" /> | ||
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#c8cacd" height="112.0" layoutX="2.0" layoutY="379.0" stroke="BLACK" strokeType="INSIDE" width="291.0" /> | ||
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#c8cacd" height="112.0" layoutX="2.0" layoutY="9.0" stroke="BLACK" strokeType="INSIDE" width="291.0" /> | ||
<Label layoutX="24.0" layoutY="278.0" prefHeight="17.0" prefWidth="110.0" text="Delete a Task" /> | ||
<Label layoutX="23.0" layoutY="18.0" prefHeight="17.0" prefWidth="162.0" text="Completed a Task" /> | ||
<Button layoutX="214.0" layoutY="53.0" mnemonicParsing="false" onAction="#done" text="Complete" /> | ||
<TextField fx:id="doneText" layoutX="24.0" layoutY="53.0" /> | ||
<Label fx:id="doneError" layoutX="24.0" layoutY="87.0" prefHeight="17.0" prefWidth="243.0" /> | ||
<Label layoutX="24.0" layoutY="388.0" prefHeight="17.0" prefWidth="149.0" text="Find a Task" /> | ||
<TextField fx:id="findText" layoutX="24.0" layoutY="410.0" /> | ||
<Button layoutX="214.0" layoutY="410.0" mnemonicParsing="false" onAction="#find" text="Find" /> | ||
</children> | ||
</AnchorPane> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These three methods seem to be very similar. See if you can reduce duplication.