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

Zhou Yang ip #469

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
55f9f9f
docs/README.md: Tweak document template
Jan 7, 2024
f837ddb
Add Gradle support
May 24, 2020
a6f7324
Bump gradle and lib version
Eclipse-Dominator Aug 5, 2023
6a2c3c4
Duke Level0
Jan 25, 2024
230d629
Duke_Level1
Jan 25, 2024
0e99f6d
Duke_Level2
Jan 25, 2024
3edd219
Duke_Level3
Jan 25, 2024
ed31075
Duke_Level4
Jan 26, 2024
c9bb7d8
Duke_Level5
Feb 1, 2024
7371a61
Duke_Level5
Feb 8, 2024
b7a9572
Duke_Level6
Feb 8, 2024
cc18fdb
Duke
Feb 21, 2024
326db9d
Duke_Level7
Feb 21, 2024
c87e0cb
Duke_Level8
Feb 23, 2024
0c8e8da
ui
Feb 23, 2024
c575fa3
Duke_Level8
Feb 24, 2024
a88f458
Duke_Level8
Feb 25, 2024
43d9349
A_Packages
Feb 25, 2024
a31ec41
Merge remote-tracking branch 'origin/add-gradle-support'
Feb 25, 2024
dc2bf14
Junit
Feb 26, 2024
5211ea8
Update
Feb 26, 2024
ecabd86
Duke_Level9
Feb 26, 2024
c4064ae
Duke_Level9
Feb 26, 2024
d16e0b4
SamuelBot
Feb 26, 2024
9985e16
SamuelBot
Feb 26, 2024
18e9e33
Merge branch 'A-CodingStandard'
Feb 26, 2024
f094fc6
Duke_Level10
Feb 26, 2024
f2fcffc
Duke_Level10
Feb 26, 2024
348cb2e
Duke_Level10
Feb 28, 2024
285b828
GUI
Feb 28, 2024
abc1856
Duke_Level10
Feb 29, 2024
ce12d48
Duke_Level9
Feb 29, 2024
14d3723
Duke_Level10
Feb 29, 2024
2ddea92
Added : class Assertions
Feb 29, 2024
efa4525
Added : class Assertions
Feb 29, 2024
242c7d6
Added Assertions.java
Feb 29, 2024
3625a37
add Assertions.java
Feb 29, 2024
46ae3ea
Merge branch 'A-Assertions' of https://github.com/SamuelZero1/ip into…
Feb 29, 2024
1a84a6b
Assertions
Feb 29, 2024
98b1583
Minor changes to ChatBotGUI.java
Feb 29, 2024
87066e5
Merge branch 'A-CodeQuality'
Feb 29, 2024
e3ca239
add UserGuide.md
Feb 29, 2024
38ad3a1
Update README.md
SamuelZero1 Feb 29, 2024
4a08237
modified some classes
Feb 29, 2024
7389801
Merge branch 'master' of https://github.com/SamuelZero1/ip
Feb 29, 2024
8631107
minor changes
Feb 29, 2024
4979698
Add files via upload
SamuelZero1 Feb 29, 2024
3d8edb8
Update README.md
SamuelZero1 Feb 29, 2024
90b394b
update SamuelBot.txt
Mar 3, 2024
48ad843
update SamuelBot.txt
Mar 3, 2024
f0295e5
run SamuelBot.txt
Mar 3, 2024
3c917f4
Update SamuelBot.txt
Mar 3, 2024
fdf5b56
Update SamuelBot.txt
Mar 3, 2024
e777fa8
Update SamuelBot.txt
Mar 3, 2024
d72ebf8
Update SamuelBot.txt
Mar 3, 2024
91d9fff
Update SamuelBot.txt
Mar 3, 2024
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
7 changes: 7 additions & 0 deletions src/main/java/Duke_Level0.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class Duke_Level0 {
public static void main(String[] args) {
System.out.println("Hello, I'm SamuelBot");
System.out.println("What can I do for you?");
System.out.println("Bye. Hope to see you again soon!");
}
}
14 changes: 14 additions & 0 deletions src/main/java/Duke_Level1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java.util.Scanner;
public class Duke_Level1 {
public static void main(String[] args) {
System.out.println("Hello! I'm SamuelBot");
System.out.println("What can I do for you?");
Scanner s = new Scanner(System.in);
String str = s.nextLine();
while(! str.equals("bye")) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should not be a space between ! and str.equals("bye")?

System.out.println(str);
str = s.nextLine();
}
System.out.println("Bye. Hope to see you again soon!");
}
}
26 changes: 26 additions & 0 deletions src/main/java/Duke_Level2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Duke_Level2 {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
System.out.println("Hello! I'm SamuelBot");
System.out.println("What can I do for you?");
Scanner s = new Scanner(System.in);
String str = s.nextLine();
while(! str.equals("bye")) {
if(str.equals("list")){
for(int i = 0; i < list.size(); i++){
System.out.println((i+1) + ". " + list.get(i));
}
}
else {
list.add(str);
System.out.println("added: " + str);
}
str = s.nextLine();
}
System.out.println("Bye. Hope to see you again soon!");
}
}
37 changes: 37 additions & 0 deletions src/main/java/Duke_Level3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Duke_Level3 {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.add("read book");
list.add("return book");
list.add("buy bread");
Scanner s = new Scanner(System.in);
String str = s.nextLine();
String[] done = new String[100];
while(true){
if(str.equals("list")){
System.out.println("Here are the tasks in your list:");
for(int i = 1; i <= list.size(); i++){
System.out.println(done[i] + list.get(i - 1));
}
}
else{
if(str.substring(0, 4).equals("mark")){
int temp = Integer.parseInt(str.substring(5));
done[temp] = "[X] ";
System.out.println("Nice! I've marked this task as done: ");
System.out.println(done[temp] + list.get(temp - 1));
}
else{
int temp = Integer.parseInt(str.substring(7));
done[temp] = "[] ";
System.out.println("OK, I've marked this task as not done yet:");
System.out.println(done[temp] + list.get(temp - 1));
}
}
str = s.nextLine();
}
}
}
85 changes: 85 additions & 0 deletions src/main/java/Duke_Level4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import java.util.ArrayList;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps consider having a package for Duke?

import java.util.List;
import java.util.Scanner;
public class Duke_Level4 {
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
System.out.println("What can I do for you?");
List<String> list = new ArrayList<>();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this variable name be updated to show that there are multiple objects represented?

Suggested change
List<String> list = new ArrayList<>();
List<String> tasks = new ArrayList<>();

String[] task = new String[100];
for (int i = 0; i < task.length; i++) {
task[i] = "[]";
}
String[] done = new String[100];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this variable can use a better name such as taskPrefixes?

for (int i = 0; i < done.length; i++) {
done[i] = "[] ";
}
Scanner s = new Scanner(System.in);
String str = s.nextLine();
while(! str.equals("bye")){
if(str.substring(0, 4).equals("mark")){
Comment on lines +24 to +25

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be a space in between if, while and the brackets?

int temp = Integer.parseInt(str.substring(5));
done[temp] = "[X] ";
System.out.println("Nice! I've marked this task as done: ");
System.out.println(task[temp] + done[temp] + list.get(temp - 1));
}
else if(str.equals("list")){
System.out.println("Here are the tasks in your list:");
for (int i = 0; i < list.size(); i++) {
System.out.println((i + 1) + ". " + task[i] + done[i] + list.get(i));
}
}
else if (str.startsWith("todo")) {
list.add(str.substring(5));
int lastIndex = list.size() - 1;
if (lastIndex >= 0) {
task[lastIndex] = "[T]";
done[lastIndex] = "[] ";
System.out.println("Got it. I've added this task:");
System.out.println(task[lastIndex] + done[lastIndex] + list.get(lastIndex));
} else {
System.out.println("Got it. I've added this task:");
System.out.println("[T][] " + list.get(0));
}
System.out.println("Now you have " + list.size() + " tasks in the list.");
}
else if(str.startsWith("event")) {
String[] splits = str.split("/from");
task[list.size()] = "[E]";
done[list.size()] = "[] ";
int idxfrom = str.indexOf("/from");
int idxto = str.indexOf("/to");
String from = str.substring(idxfrom + 6, idxto);
String to = str.substring(idxto + 4);
String temp = "(from: " + from + "to: " + to + ")";
list.add(splits[0] + temp);
System.out.println("Got it. I've added this task:");
System.out.println(task[list.size() - 1] + done[list.size() - 1] + list.get(list.size() - 1));
System.out.println("Now you have " + list.size() + " tasks in the list.");
}
else if(str.startsWith("unmark")) {
int temp = Integer.parseInt(str.substring(7));
done[temp] = "[] ";
System.out.println("OK, I've marked this task as not done yet:");
System.out.println(task[temp] + done[temp] + list.get(temp - 1));
}
else if(str.startsWith("deadline")){
task[list.size()] = "[D]";
done[list.size()] = "[] ";
String temp = " (by: " + str.split("/by")[1].trim() + ")";
list.add(str.substring(8).split("/by")[0].trim() + temp);
System.out.println("Got it. I've added this task:");
System.out.println(task[list.size() - 1] + done[list.size() - 1] + list.get(list.size() - 1));
System.out.println("Now you have " + list.size() + " tasks in the list.");
}
str = s.nextLine();
}
System.out.println("Bye. Hope to see you again soon!");
}
}

2 changes: 2 additions & 0 deletions src/main/java/Duke_Level5.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package PACKAGE_NAME;public class Duke_Level5 {
}
2 changes: 2 additions & 0 deletions src/main/java/EventTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package PACKAGE_NAME;public class EventTask {
}
2 changes: 2 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package PACKAGE_NAME;public class Task {
}