-
Notifications
You must be signed in to change notification settings - Fork 191
[Edwin] iP #191
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
Open
yzhedwin
wants to merge
36
commits into
nus-cs2113-AY2122S1:master
Choose a base branch
from
yzhedwin:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Edwin] iP #191
Changes from 5 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
bcf20ee
Week 2 Task
yzhedwin 2c2a310
Level-1
yzhedwin da7c42b
Level-2
yzhedwin 7e2f13a
Level-3
yzhedwin 0b9ce39
Completed A-CodingStandard
yzhedwin 074899d
Level-4 Completed
yzhedwin 4ce8ac0
Level-4, A-CodeQuality
yzhedwin c2a8cf3
Completed Level-5
yzhedwin e61f1e7
Completed Level-5,A-Exceptions
yzhedwin daef42c
Updated Ui Testing
yzhedwin 3fc7b81
Created new branch as part of increments
yzhedwin ed20d64
Merge branch-Level-5 with master
yzhedwin e8ce66f
Completed A-Packages and improve coding standards
yzhedwin acfd97c
Merge branch-A-Packages with master
yzhedwin 88ad15e
Updated runtest.bat
yzhedwin d3cbc29
Formatted some codes
yzhedwin b573d4c
Code Fixes
yzhedwin 3974bd3
Improved A-Exception
yzhedwin 22af079
Added delete feature
yzhedwin 3c647fc
Added save feature and some personality for Level-7 requirement
yzhedwin a294af8
Minor changes to save.txt
yzhedwin 86a9032
Merge branch Level-6 with master
yzhedwin c3af9c5
Merge branch Level-7 with master
yzhedwin 92cbe7d
Added more OOP and fixed exception handling
yzhedwin ea44036
Added Date and Time functionality
yzhedwin d57c1a3
Merge pull request #1 from yzhedwin/branch-Level-8
yzhedwin a2984d6
Added Find Feature
yzhedwin 4a890e0
Merge pull request #2 from yzhedwin/branch-Level-9
yzhedwin 8a47b70
Documentation for A-JavaDoc
yzhedwin 5217ca0
Merge pull request #3 from yzhedwin/branch-A-JavaDoc
yzhedwin d3eb8f0
Updated JavaDoc
yzhedwin 468e2f1
Completed User Guide
yzhedwin 9c9496a
Set theme jekyll-theme-cayman
yzhedwin 0f9c8b7
Completed User Guide
yzhedwin 788449d
Merge branch 'master' of github.com:yzhedwin/ip
yzhedwin e8616f6
Build ip.jar
yzhedwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { | ||
| 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); | ||
|
|
||
|
||
| } 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); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)))); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| //... | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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