Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bcf20ee
Week 2 Task
yzhedwin Aug 22, 2021
2c2a310
Level-1
yzhedwin Aug 26, 2021
da7c42b
Level-2
yzhedwin Aug 26, 2021
7e2f13a
Level-3
yzhedwin Aug 26, 2021
0b9ce39
Completed A-CodingStandard
yzhedwin Aug 26, 2021
074899d
Level-4 Completed
yzhedwin Sep 3, 2021
4ce8ac0
Level-4, A-CodeQuality
yzhedwin Sep 3, 2021
c2a8cf3
Completed Level-5
yzhedwin Sep 7, 2021
e61f1e7
Completed Level-5,A-Exceptions
yzhedwin Sep 7, 2021
daef42c
Updated Ui Testing
yzhedwin Sep 7, 2021
3fc7b81
Created new branch as part of increments
yzhedwin Sep 7, 2021
ed20d64
Merge branch-Level-5 with master
yzhedwin Sep 7, 2021
e8ce66f
Completed A-Packages and improve coding standards
yzhedwin Sep 7, 2021
acfd97c
Merge branch-A-Packages with master
yzhedwin Sep 7, 2021
88ad15e
Updated runtest.bat
yzhedwin Sep 7, 2021
d3cbc29
Formatted some codes
yzhedwin Sep 7, 2021
b573d4c
Code Fixes
yzhedwin Sep 7, 2021
3974bd3
Improved A-Exception
yzhedwin Sep 7, 2021
22af079
Added delete feature
yzhedwin Sep 15, 2021
3c647fc
Added save feature and some personality for Level-7 requirement
yzhedwin Sep 16, 2021
a294af8
Minor changes to save.txt
yzhedwin Sep 16, 2021
86a9032
Merge branch Level-6 with master
yzhedwin Sep 16, 2021
c3af9c5
Merge branch Level-7 with master
yzhedwin Sep 16, 2021
92cbe7d
Added more OOP and fixed exception handling
yzhedwin Sep 27, 2021
ea44036
Added Date and Time functionality
yzhedwin Sep 29, 2021
d57c1a3
Merge pull request #1 from yzhedwin/branch-Level-8
yzhedwin Sep 29, 2021
a2984d6
Added Find Feature
yzhedwin Sep 29, 2021
4a890e0
Merge pull request #2 from yzhedwin/branch-Level-9
yzhedwin Sep 29, 2021
8a47b70
Documentation for A-JavaDoc
yzhedwin Sep 29, 2021
5217ca0
Merge pull request #3 from yzhedwin/branch-A-JavaDoc
yzhedwin Sep 29, 2021
d3eb8f0
Updated JavaDoc
yzhedwin Sep 29, 2021
468e2f1
Completed User Guide
yzhedwin Sep 30, 2021
9c9496a
Set theme jekyll-theme-cayman
yzhedwin Sep 30, 2021
0f9c8b7
Completed User Guide
yzhedwin Sep 30, 2021
788449d
Merge branch 'master' of github.com:yzhedwin/ip
yzhedwin Sep 30, 2021
e8616f6
Build ip.jar
yzhedwin Sep 30, 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
48 changes: 48 additions & 0 deletions src/main/java/Circle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
public class Circle {
private int x;
private int y;
private double radius;
private static double maxRadius = 0;

public Circle(){
this(0, 0, 0);
}

public Circle(int x, int y, double radius){
setX(x);
setY(y);
setRadius(radius);
}

public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}

public void setY(int y) {
this.y = y;
}

public double getRadius() {
return radius;
}

public void setRadius(double radius) {
this.radius = Math.max(radius, 0);
if (maxRadius < this.radius){
maxRadius = this.radius;
}
}
public static double getMaxRadius() {
return maxRadius;
}
public int getArea(){
double area = Math.PI * Math.pow(radius, 2);
return (int)area;
}
}
45 changes: 44 additions & 1 deletion src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,53 @@
import java.util.Scanner;

public class Duke {
private static Task[] items = new Task[100];
private static int taskCount = 0;

public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
String border = "____________________________________________________________\n";
System.out.println(border + "Hi bro, my name is Echo");
System.out.println("What do you want?\n" + border);
System.out.println("Type bye to exit\n" + border);
String line;

do {
Copy link

Choose a reason for hiding this comment

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

maybe can move the while loop to a new method, and call that method instead, following single level of abstraction

Scanner in = new Scanner(System.in);
line = in.nextLine();
if (line.matches("list")) {
int j = 1;
System.out.println(border);
for (Task item : items) {
if (item != null) {
System.out.println(j + ".[" + item.getStatusIcon() + "] " + item.getDescription());
j++;
}
}
System.out.println(border);

Copy link

Choose a reason for hiding this comment

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

May not need an extra newline here

} else if (line.contains("done")) {
int dividerPosition = line.indexOf(" ") + 1;
int endPosition = line.length();
if (endPosition > 5) {
String num = line.substring(dividerPosition, endPosition);
int taskNum = Integer.parseInt(num) - 1;
items[taskNum].markDone();
System.out.println(border + "Nice! task is done " + '\n' + border);
}
} else if (!line.matches("bye")) {
System.out.println(border + "added: " + line + '\n' + border);
Task newItem = new Task(line);
items[taskCount] = newItem;
taskCount++;
}
}
while (!line.matches("bye"));
System.out.println(border);
System.out.println("chat again next time!\n" + border);
}
}
47 changes: 47 additions & 0 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

import java.util.Arrays;
import java.util.Scanner;

public class Main {

// You can add more methods here
public static String[] filter(String[] items){
String[] results = new String[items.length];
int matchCount = 0;
for(String item: items){
if (item.contains("$")){
results[matchCount] = item;
matchCount++;
}
}
return Arrays.copyOf(results, matchCount);
}

public static double totalExpenses(String[] prices) {
double total = 0;
for (String price : prices) {
total += Double.parseDouble(price.trim().replace("$"," "));
}
return total;
}
public static double exchangeRate(double overseas) {
return overseas * 1.70;
}
public static String[] splitSentence(String sentence) {
return sentence.split(" ");
}

public static void main(String[] args) {
String line;
Scanner in = new Scanner(System.in);

System.out.print("Your expenses while overseas?");
// TODO: add your code here
line = in.nextLine();
String[] amounts = filter(splitSentence(line));
System.out.print("Expenses in overseas currency:");
System.out.println(Arrays.toString(amounts));
System.out.print("Total in local currency: ");
System.out.println("$" + String.format("%.2f", exchangeRate(totalExpenses(amounts))));
}
}
21 changes: 21 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
public class Task {
protected String description;
protected boolean isDone;

public Task(String description) {
this.description = description;
this.isDone = false;
}

public String getStatusIcon() {
return (isDone ? "X" : " "); // mark done task with X
}
public String getDescription() {
return this.description;
}

public void markDone() {
this.isDone = true;
}
//...
}