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

[AY1920S1-CS2113T-F14-3] No Name #38

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added production/main/Duke.class
Binary file not shown.
Binary file added src/main/java/Command.class
Binary file not shown.
4 changes: 4 additions & 0 deletions src/main/java/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class Command {
public void execute(Ui ui, Tasklist tasks, Storage storage){
}
}
Binary file added src/main/java/CommandAdd.class
Binary file not shown.
10 changes: 10 additions & 0 deletions src/main/java/CommandAdd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class CommandAdd extends Command {
private Task task;
public CommandAdd(Task task){
this.task = task;
}

public void execute(Ui ui, Tasklist tasks, Storage storage){
ui.showAction(tasks.add(task));
}
}
Binary file added src/main/java/CommandDelete.class
Binary file not shown.
17 changes: 17 additions & 0 deletions src/main/java/CommandDelete.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
public class CommandDelete extends Command{
private int index;

public CommandDelete(int index){
this.index = index;
}

@Override
public void execute(Ui ui, Tasklist tasks, Storage storage){
try {
ui.showAction(tasks.delete(index));
}
catch (IndexOutOfBoundsException e){
System.out.println(" The task index doesn't exist");
}
}
}
Binary file added src/main/java/CommandDone.class
Binary file not shown.
17 changes: 17 additions & 0 deletions src/main/java/CommandDone.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
public class CommandDone extends Command {
private int index;

public CommandDone(int index){
this.index = index;
}

@Override
public void execute(Ui ui, Tasklist tasks, Storage storage){
try {
ui.showAction(tasks.done(index));
}
catch (IndexOutOfBoundsException e){
System.out.println(" The task index doesn't exist");
}
}
}
Binary file added src/main/java/CommandExit.class
Binary file not shown.
6 changes: 6 additions & 0 deletions src/main/java/CommandExit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class CommandExit extends Command {
@Override
public void execute(Ui ui, Tasklist tasks, Storage storage){
ui.showGoodbye();;
}
}
Binary file added src/main/java/CommandFind.class
Binary file not shown.
12 changes: 12 additions & 0 deletions src/main/java/CommandFind.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class CommandFind extends Command {
private String keyword;

public CommandFind(String keyword){
this.keyword = keyword;
}

@Override
public void execute(Ui ui, Tasklist tasks, Storage storage){
ui.showAction(tasks.find(keyword));
}
}
Binary file added src/main/java/CommandList.class
Binary file not shown.
6 changes: 6 additions & 0 deletions src/main/java/CommandList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class CommandList extends Command{
@Override
public void execute(Ui ui, Tasklist tasks, Storage storage){
ui.showAction(tasks.toString());
}
}
Binary file added src/main/java/CommandUnknown.class
Binary file not shown.
6 changes: 6 additions & 0 deletions src/main/java/CommandUnknown.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class CommandUnknown extends Command {
@Override
public void execute(Ui ui, Tasklist tasks, Storage storage){
ui.showAction(" Unrecognized command\n");
}
}
Binary file added src/main/java/Date.class
Binary file not shown.
31 changes: 31 additions & 0 deletions src/main/java/Date.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
enum Months{
January, February, March, April, May, June, July, August, September, October, November, December;
}
public class Date {
private String representation;
public Date(String date){
String arr[] = date.split("/",3);
int day = Integer.parseInt(arr[0]);
int month = Integer.parseInt(arr[1]);
Months list[] = Months.values();
if (day % 10 == 1){
arr[0] += "st";
}
else if (day % 10 == 2){
arr[0] += "nd";
}
else if (day % 10 == 3){
arr[0] += "rd";
}
else{
arr[0] += "th";
}
arr[1] = list[month - 1].name();
representation = arr[0] + " of " + arr[1] + " " + arr[2];
}

@Override
public String toString(){
return representation;
}
}
Binary file added src/main/java/Deadline.class
Binary file not shown.
28 changes: 28 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class Deadline extends Task{
private String by;
private Date date;
private Time time;
public Deadline(String name, String by) {
super(name);
this.by = by;

String arr[] = by.split(" ", 3);
date = new Date(arr[1]);
time = new Time(arr[2]);
}

@Override
public String getTime(){
return this.by;
}

@Override
public String toString(){
return "[D] " + super.toString() + " (by:" + date.toString() + " " + time.toString() + ")";
}

@Override
public String saveForm(){
return "[D]:"+ super.tick() + ":" + super.getName() + ":" + by;
}
}
Binary file added src/main/java/Duke.class
Binary file not shown.
11 changes: 11 additions & 0 deletions src/main/java/Duke.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
58 changes: 58 additions & 0 deletions src/main/java/Duke.ipr
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
</profile>
<version value="1.0" />
</component>
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Duke.iml" filepath="$PROJECT_DIR$/Duke.iml" />
</modules>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
<component name="masterDetails">
<states>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<last-edited>11</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
74 changes: 74 additions & 0 deletions src/main/java/Duke.iws
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="61b13721-62b1-4ceb-92d8-2ea468da3e47" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Interface" />
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="ProjectId" id="1QF51B8QfcjVx9RYOaevDTbwQAW" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="PropertiesComponent">
<property name="project.structure.last.edited" value="SDKs" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.2" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
</component>
<component name="RunAnythingCache">
<option name="myCommands">
<command value="java *.java" />
<command value="javac Duke.java Task.java Date.java Time.java Todo.java Deadline.java Event.java" />
<command value="java Duke" />
<command value="javac *.java" />
<command value="ls -a" />
</option>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="61b13721-62b1-4ceb-92d8-2ea468da3e47" name="Default Changelist" comment="" />
<created>1567353285367</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1567353285367</updated>
</task>
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State>
<option name="COLUMN_ORDER" />
</State>
</value>
</entry>
</map>
</option>
</component>
</project>
40 changes: 30 additions & 10 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
public class Duke {
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
}
}

public class Duke{
private Tasklist tasks;
private Ui ui;
private Storage storage;

public Duke(String filepath){
ui = new Ui();
storage = new Storage(filepath);
try {
tasks = new Tasklist(storage.load());
} catch (Exception e) {
tasks = new Tasklist();
}
}

public void run() throws Exception{
ui.showWelcome();
while (!ui.exit()) {
String fullCommand = ui.readCommand();
Command c = Parser.parse(fullCommand);
c.execute(ui, tasks, storage);
}
storage.write(tasks.list());
}

public static void main(String args[]) throws Exception {
new Duke("data.txt").run();
}
}
Binary file added src/main/java/Event.class
Binary file not shown.
28 changes: 28 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class Event extends Task{
private String by;
private Date date;
private Time time;
public Event(String name, String by) {
super(name);
this.by = by;

String arr[] = by.split(" ", 3);
date = new Date(arr[1]);
time = new Time(arr[2]);
}

@Override
public String getTime(){
return this.by;
}

@Override
public String toString(){
return "[E] " + super.toString() + " (by:" + date.toString() + " " + time.toString() + ")";
}

@Override
public String saveForm(){
return "[E]:"+ super.tick() + ":" + super.getName() + ":" + by;
}
}
Binary file added src/main/java/Months.class
Binary file not shown.
Binary file added src/main/java/Parser.class
Binary file not shown.
Loading