Skip to content
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

[Rama Venkatesh] iP #503

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
d839859
Add Gradle support
May 24, 2020
a5e37a0
Level-1
ramaven Aug 19, 2021
9f114de
Level-2
ramaven Aug 19, 2021
254a843
Level-3
ramaven Aug 19, 2021
dcbae92
Level-4
ramaven Aug 19, 2021
cba3a3a
Level-5
ramaven Aug 19, 2021
ec3c11f
Level-6
ramaven Aug 19, 2021
913b02f
modified expected output
ramaven Sep 2, 2021
75ec70d
enum & refactoring
ramaven Sep 2, 2021
76f877c
enum; refactoring
ramaven Sep 2, 2021
d6610f1
added save functionality
ramaven Sep 5, 2021
6e00451
added save
ramaven Sep 5, 2021
a4d5124
Added DukeDate parse
ramaven Sep 6, 2021
98be0ed
Merge branch 'master' into branch-Level-8
ramaven Sep 6, 2021
bb01e2e
Merge pull request #1 from ramaven/branch-Level-8
ramaven Sep 6, 2021
f54b7d8
fixed getDate() bug
ramaven Sep 6, 2021
6e50441
refactored packages
ramaven Sep 6, 2021
54125a4
removed debug statements
ramaven Sep 6, 2021
c471774
added Command class; OOP
ramaven Sep 6, 2021
b330b0d
adhered coding standard
ramaven Sep 11, 2021
35c0733
adhered coding standard
ramaven Sep 11, 2021
49b8c33
added javadocs
ramaven Sep 11, 2021
a5955e0
added find functionality
ramaven Sep 11, 2021
0dd98f3
Merge pull request #2 from ramaven/branch-A-CodingStandard
ramaven Sep 11, 2021
deafde9
Merge pull request #3 from ramaven/branch-A-JavaDoc
ramaven Sep 11, 2021
80d6917
Merge pull request #4 from ramaven/branch-Level-9
ramaven Sep 11, 2021
84bc195
Merge pull request #6 from ramaven/add-gradle-support
ramaven Sep 12, 2021
f1722c7
fixed file save bug
ramaven Sep 12, 2021
90738d5
fixed file save bug
ramaven Sep 12, 2021
8c536cb
added gradle support
ramaven Sep 12, 2021
1848605
Merge branch 'master' into branch-A-Gradle
ramaven Sep 12, 2021
6657c54
Merge pull request #7 from ramaven/branch-A-Gradle
ramaven Sep 12, 2021
d183176
checkstyle
ramaven Sep 12, 2021
559aa07
Merge pull request #8 from ramaven/branch-A-Checkstyle
ramaven Sep 12, 2021
6137ed5
modified gradle build file
ramaven Sep 12, 2021
99eeead
Merge branch 'master' into branch-A-Checkstyle
ramaven Sep 12, 2021
0dc6f8e
Merge pull request #9 from ramaven/branch-A-Checkstyle
ramaven Sep 12, 2021
48c8b01
Added GUI
ramaven Sep 13, 2021
6f08fb4
Merge pull request #10 from ramaven/branch-Level-10
ramaven Sep 13, 2021
a6c7cec
Add assert statements
ramaven Sep 14, 2021
431ad92
Merge pull request #11 from ramaven/branch-A-Assertions
ramaven Sep 14, 2021
b919c18
Find command: make matching case insensitive
ramaven Sep 14, 2021
23b81b1
Merge pull request #12 from ramaven/branch-C-BetterSearch
ramaven Sep 14, 2021
6735ff4
Improve code quality
ramaven Sep 15, 2021
85deaac
Merge pull request #13 from ramaven/branch-A-CodeQuality
ramaven Sep 15, 2021
375ee70
Add product screenshot
ramaven Sep 15, 2021
5db5d46
Add user guide
ramaven Sep 15, 2021
790acc6
Set theme jekyll-theme-minimal
ramaven Sep 15, 2021
b5d33a9
Set theme jekyll-theme-leap-day
ramaven Sep 15, 2021
1e5ca13
Edit User Guide
ramaven Sep 15, 2021
0557aa0
Merge branch 'master' of https://github.com/ramaven/ip
ramaven Sep 15, 2021
855c0ad
Update README
ramaven Sep 15, 2021
dc82355
Update README.md
ramaven Sep 15, 2021
27a3096
Update README.md
ramaven Sep 15, 2021
f17b05f
Update README.md
ramaven Sep 15, 2021
a9ce5a5
Add credits
ramaven Sep 15, 2021
979f83f
Improve code quality
ramaven Sep 15, 2021
8e8c1d7
Add test methods
ramaven Sep 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed file save bug
ramaven committed Sep 12, 2021
commit 90738d5089726346662d58c28e40438bf155b60c
398 changes: 398 additions & 0 deletions config/checkstyle/checkstyle.xml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">

<suppressions>
<suppress checks="JavadocType" files=".*Test\.java"/>
<suppress checks="MissingJavadocMethodCheck" files=".*Test\.java"/>
</suppressions>
1 change: 1 addition & 0 deletions data.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
T;0;readbook
D;0;return book ;2/12/2019 1800
T;0;week 4 ip
22 changes: 13 additions & 9 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import java.io.FileNotFoundException;

import duke.commands.Command;
import duke.utils.Parser;
import duke.utils.Storage;
import duke.utils.TaskList;
import duke.utils.Ui;

import java.io.FileNotFoundException;

/**
* Command Line Task Manager called Duke
@@ -22,32 +23,35 @@ public class Duke {
/**
* Constructor that instantiates Duke
*/
public Duke(){
public Duke() {
ui = new Ui();
parser = new Parser();
this.storage = new Storage();
try{
try {
taskList = storage.loadTaskList();
} catch(FileNotFoundException e){
} catch (FileNotFoundException e) {
System.out.println(e.getMessage());
}

}

public void run(){
/**
* Method to start running the application
*/
public void run() {
ui.start();
boolean isExit = false;

while(!isExit){
try{
while (!isExit) {
try {
String fullCommand = ui.readCommand();
ui.showLine(); // show the divider line ("_______")
Command c = parser.parseInput(fullCommand);
c.execute(taskList, ui, storage);
isExit = c.isExit();


} catch (Exception e){
} catch (Exception e) {
ui.showError(e);
} finally {
ui.showLine();
@@ -61,7 +65,7 @@ public void run(){
* Commences Duke
* @param args CLI arguments
*/
public static void main(String[] args){
public static void main(String[] args) {

new Duke().run();

4 changes: 3 additions & 1 deletion src/main/java/duke/commands/Command.java
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@
import duke.exceptions.DukeException;
import duke.utils.*;

import java.io.IOException;

/**
* Abstract class that represents a Command in the application
*/
@@ -15,7 +17,7 @@ public abstract class Command {
* @param storage the Storage object that is being used in the app
* @throws DukeException
*/
public abstract void execute(TaskList taskList, Ui ui, Storage storage) throws DukeException;
public abstract void execute(TaskList taskList, Ui ui, Storage storage) throws DukeException, IOException;

/**
* Returns whether or not this command is an exit command
7 changes: 5 additions & 2 deletions src/main/java/duke/commands/ExitCommand.java
Original file line number Diff line number Diff line change
@@ -2,14 +2,17 @@

import duke.utils.*;

import java.io.IOException;

/**
* Class that is a subclass of Command class
* and handles the behaviour of the Command for
* when exiting the program
*/
public class ExitCommand extends Command{
public class ExitCommand extends Command {
@Override
public void execute(TaskList task, Ui ui, Storage storage){
public void execute(TaskList tasks, Ui ui, Storage storage) throws IOException {
storage.saveTaskListToDisk(tasks);
ui.end();
}

28 changes: 15 additions & 13 deletions src/main/java/duke/utils/Storage.java
Original file line number Diff line number Diff line change
@@ -37,22 +37,22 @@ public TaskList loadTaskList() throws FileNotFoundException {
File f = new File(dataFilePath);
ArrayList<Task> taskList = new ArrayList<Task>();

if(!f.exists()){
if (!f.exists()) {
return new TaskList(new ArrayList<Task>());
}

try{
try {
Scanner dataReader = new Scanner(f);

while(dataReader.hasNextLine()){
while (dataReader.hasNextLine()) {
// convert saved info to Task
String currLine = dataReader.nextLine();
Task currTask = convertStringToTask(currLine);
taskList.add(currTask);
}
dataReader.close();

} catch (FileNotFoundException e){
} catch (FileNotFoundException e) {
System.out.println("File unable to load");
}

@@ -67,34 +67,36 @@ public TaskList loadTaskList() throws FileNotFoundException {
* @param taskList tasklist
* @throws IOException
*/
public void saveTaskListToDisk(TaskList taskList) throws IOException{

public void saveTaskListToDisk(TaskList taskList) throws IOException {
File f = new File(dataFilePath);
if(!f.exists()) {
try{
if (!f.exists()) {
try {
boolean created = f.createNewFile();
} catch (IOException e) {
System.out.println("Error creating file");
}
}

try{
try {
FileWriter writeTasks = new FileWriter(dataFilePath);
String allTasksString = "";

for(int i = 0; i < taskList.numberOfTasks(); i++){
for (int i = 0; i < taskList.numberOfTasks(); i++) {
Task currTask = taskList.getTask(i);
String taskString = convertTaskToString(currTask);
allTasksString += taskString + "\n";
System.out.println("written" + taskString);

}

writeTasks.write(allTasksString);
writeTasks.flush();
writeTasks.close();
System.out.println("I have saved your tasks.");



} catch (IOException e){
} catch (IOException e) {
System.out.println("Error creating file");
}

@@ -107,7 +109,7 @@ public void saveTaskListToDisk(TaskList taskList) throws IOException{
* @param task
* @return String representation of the task
*/
public String convertTaskToString(Task task){
public String convertTaskToString(Task task) {


// Example storage in file:
@@ -160,7 +162,7 @@ public Task convertStringToTask(String line){

Task currTask;

switch (taskType){
switch (taskType) {
case TODO:
currTask = new TodoTask(lineSplit[2]);
break;