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

[YFshadaow] ip #80

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a611e8d
Feature: Bot greets user and exists.
YFshadaow Aug 30, 2023
030308b
Feature:
YFshadaow Aug 30, 2023
37b8d43
Fix run and test scripts
YFshadaow Sep 6, 2023
f4b1e20
Move code away from default package
YFshadaow Sep 6, 2023
9922052
Feature:
YFshadaow Sep 6, 2023
0d227e6
Feature:
YFshadaow Sep 6, 2023
8ccd6b9
Feature: Add type to tasks
YFshadaow Sep 6, 2023
39ef31d
Optimize code according to github reviews
YFshadaow Sep 20, 2023
f16e73f
Optimize error logging
YFshadaow Sep 20, 2023
5d257a6
Optimize package structure
YFshadaow Sep 20, 2023
a580355
Merge branch 'branch-Level-5'
YFshadaow Sep 20, 2023
1dc55b3
Add Command.java: Update command parsing logic
YFshadaow Oct 4, 2023
e94935f
Eliminate warnings
YFshadaow Oct 4, 2023
c499c98
Add delete command
YFshadaow Oct 4, 2023
9501edc
Add feature of saving task data as json file
YFshadaow Oct 4, 2023
90133e0
Update .gitignore
YFshadaow Oct 4, 2023
c307ba6
Remove debug logging
YFshadaow Oct 4, 2023
40c399a
Update pom.xml
YFshadaow Oct 4, 2023
fa531e9
Merge branch 'branch-Level-6'
YFshadaow Oct 4, 2023
cb847e4
Merge branch-Level 7 into master
YFshadaow Oct 4, 2023
928f9a5
Extract methods to new classes for better OOP
YFshadaow Oct 4, 2023
291a236
Add find command: Allow user search for tasks using keywords
YFshadaow Oct 4, 2023
3f78a79
Add javadoc
YFshadaow Oct 4, 2023
d6d295d
Merge pull request #1 from YFshadaow/branch-Level-9
YFshadaow Oct 4, 2023
bad7bbd
Merge pull request #2 from YFshadaow/branch-A-JavaDoc
YFshadaow Oct 4, 2023
5bac8fa
Update README.md
YFshadaow Oct 4, 2023
af73b7f
Update artifact name in pom.xml
YFshadaow Oct 5, 2023
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ bin/

/text-ui-test/ACTUAL.TXT
text-ui-test/EXPECTED-UNIX.TXT

# Bot data files
/data/

# Maven build files
/target/
68 changes: 54 additions & 14 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,69 @@
# User Guide
# XiaoAi User Guide

## Features

### Feature-ABC
### Feature: Add tasks

Description of the feature.
You can add your tasks to the task list.

### Feature-XYZ
### Feature: Delete tasks

Description of the feature.
You can delete an existing task from the task list.

### Feature: List tasks

You can list all existing tasks.

### Feature: Mark task as done/not done

You can mark an existing task as done/not done.

### Feature: Find tasks

You can search for tasks using keywords.

## Usage

### `Keyword` - Describe action
### `todo` - adds a todo task

usage: `todo <name...>`
example usage: `todo drink some coffee`

### `deadline` - adds a deadline task

usage: `deadline <name...> -by <by...>`
example usage: `deadline submit assignment -by today 7pm`

### `event` - adds an event task

usage: `event <name...> -from <from...> -to <to...>`
example usage: `event go to concert -from 11/7 8pm -to 11/7 10pm`

### `list` - list all existing tasks

usage: `list`

### `delete` - delete a task with index

usage: `delete <index>`
example usage: `delete 3`

### `mark` - mark a task as done

usage: `mark <index>`
example usage: `mark 3`

### `unmark` - mark a task as not done

Describe the action and its outcome.
usage: `unmark <index>`
example usage: `unmark 3`

Example of usage:
### `find` - find all tasks with name containing the keywords

`keyword (optional arguments)`
usage: `find <keyword...>`
example usage: `find read books`

Expected outcome:
### `bye` - stop the bot and quit

Description of the outcome.
usage: `bye`

```
expected output
```
91 changes: 91 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>cn.yfshadaow.cs2113.ip</groupId>
<artifactId>XiaoAiBot</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>XiaoAiBot</name>

<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>cn.yfshadaow.cs2113.ip.Duke</Main-Class>
<Build-Number>1.0</Build-Number>
</manifestEntries>
</transformer>
</transformers>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>3.2.0</version>
</plugin>
</plugins>
<defaultGoal>install</defaultGoal>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

<dependencies>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.errorprone/error_prone_annotations -->
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
<version>2.22.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.14.0</version>
</dependency>

</dependencies>
</project>
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

17 changes: 17 additions & 0 deletions src/main/java/cn/yfshadaow/cs2113/ip/Duke.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cn.yfshadaow.cs2113.ip;

/**
* The main class for the application
*/
public class Duke {

/**
* The entry point of application.
*
* @param args the input arguments
*/
public static void main(String[] args) {
XiaoAiBot bot = new XiaoAiBot();
bot.start();
}
}
117 changes: 117 additions & 0 deletions src/main/java/cn/yfshadaow/cs2113/ip/XiaoAiBot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package cn.yfshadaow.cs2113.ip;

import cn.yfshadaow.cs2113.ip.command.Command;
import cn.yfshadaow.cs2113.ip.command.CommandHandler;
import cn.yfshadaow.cs2113.ip.storage.Storage;
import cn.yfshadaow.cs2113.ip.ui.Ui;
import cn.yfshadaow.cs2113.ip.utils.Parser;
import cn.yfshadaow.cs2113.ip.utils.TaskList;
import com.google.gson.JsonParseException;

import java.io.IOException;

/**
* Represents a bot.
*/
public class XiaoAiBot {

private final Storage storage = new Storage();

/**
* Gets storage.
*
* @return the storage
*/
@SuppressWarnings("unused")
public Storage getStorage() {
return storage;
}

private final Ui ui = new Ui(this);

/**
* Gets ui.
*
* @return the ui
*/
@SuppressWarnings("unused")
public Ui getUi() {
return ui;
}

private final TaskList taskList = new TaskList();

/**
* Gets task list.
*
* @return the task list
*/
@SuppressWarnings("unused")
public TaskList getTaskList() {
return taskList;
}


/**
* Gets command handler.
*
* @return the command handler
*/
@SuppressWarnings("unused")
public CommandHandler getCommandHandler() {
return commandHandler;
}

private final CommandHandler commandHandler = new CommandHandler(this);

/**
* Sets whether the bot should quit.
*
* @param shouldQuit whether the bot should quit
*/
public void setShouldQuit(boolean shouldQuit) {
this.shouldQuit = shouldQuit;
}

private boolean shouldQuit = false;

private void initialize() throws IOException{
storage.initialize();
try {
taskList.tasks.addAll(storage.loadData().tasks);
ui.sendMessage("Successfully loaded data from data file");
} catch (JsonParseException e) {
ui.sendMessage(String.format("Failed to load data becauseJSON parsing failed: %s", e.getMessage()));
} catch (Exception e) {
ui.sendMessage(String.format("Failed to load data from data file: %s", e.getMessage()));
}
}


/**
* Start the bot.
*/
public void start() {
try {
initialize();
} catch (Exception e) {
ui.sendMessage(String.format("Bot initialization failed: %s", e.getMessage()));
return;
}
ui.greet();

while (!shouldQuit) {
String commandString = ui.readLine();
Command cmd;
try {
cmd = Parser.parseCommand(commandString);
} catch (IllegalArgumentException e) {
ui.sendMessage(String.format("Error parsing command: %s", e.getMessage()));
continue;
}
commandHandler.handleCommand(cmd);
}

ui.farewell();
}
}
53 changes: 53 additions & 0 deletions src/main/java/cn/yfshadaow/cs2113/ip/command/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package cn.yfshadaow.cs2113.ip.command;

import java.util.*;

/**
* Represents a command. A command must have a name, but might have empty arguments and extra arguments.
*/
public class Command {
private String name;

/**
* Gets name.
*
* @return the name
*/
@SuppressWarnings("unused")
public String getName() {
return name;
}

/**
* Sets name.
*
* @param name the name
*/
@SuppressWarnings("unused")
public void setName(String name) {
this.name = name;
}

/**
* The Args.
*/
public final List<String> args = new ArrayList<>();
/**
* The Extra args.
*/
public final Map<String, String> extraArgs = new HashMap<>();

/**
* Instantiates a new Command.
*
* @param name the name
* @param args the args
* @param extraArgs the extra args
*/
public Command(String name, List<String> args, Map<String, String> extraArgs) {
this.name = name;
this.args.addAll(args);
this.extraArgs.putAll(extraArgs);
}

}
Loading