-
Notifications
You must be signed in to change notification settings - Fork 114
[DarkDragoon2002] iP #95
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
90c8452
6027a2d
0d164dd
dded6bf
d0d0bda
a43c3b2
6a7f020
0d50273
cb16bf3
913e641
f0c0fab
36dbaff
2d8b65a
5b59c6f
c4ca544
f0b78b9
0941170
9672976
2d5e67e
c88fc8c
e2f954e
1e844eb
44b8d55
43e739f
075bdcf
8eff0ee
01d0c9d
cdf58d0
8d0bb25
4e5f9fa
2935ec3
e439f74
936c109
42cbb2c
364eab3
e64f9dc
16bf1b5
97be193
45abc71
4175b23
98d3df5
246fbcb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import java.util.Scanner; | ||
|
|
||
| public class Juan { | ||
| public static void main(String[] args) { | ||
| lineMessage(); | ||
| helloMessage(); | ||
| lineMessage(); | ||
|
|
||
| boolean continueChatting = true; | ||
| while (continueChatting) { | ||
| continueChatting = chatFeature(); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be better to extract these lines of code? |
||
| byeMessage(); | ||
| lineMessage(); | ||
| } | ||
| public static boolean chatFeature(){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it's a method, should it be named with a verb? |
||
| // Less efficient to create a new scanner everytime but code is much neater | ||
| // If return True means continue | ||
| // Else End | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment looks like a note to self and should not be here |
||
|
|
||
| Scanner scanner = new Scanner(System.in); | ||
| String line = scanner.nextLine(); | ||
| lineMessage(); | ||
|
|
||
| if (line.equals("bye")) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May the command words also be variables, for later use or easier management? |
||
| return false; | ||
| } else if (line.equals("list")) { | ||
| Task.printTasksList(); | ||
| return true; | ||
| } | ||
|
|
||
| // Check for mark and unmark or just add task | ||
| String[] parts = line.split(" "); | ||
| if (parts[0].equals("mark")){ | ||
| // Mark | ||
| int taskIndex = Integer.parseInt(parts[1]) - 1; | ||
| Task.mark(taskIndex); | ||
| } else if (parts[0].equals("unmark")){ | ||
| // Unmark | ||
| int taskIndex = Integer.parseInt(parts[1]) - 1; | ||
| Task.unmark(taskIndex); | ||
| } else { | ||
| // else add task | ||
| Task newTask = new Task(line); | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this part be extracted out? |
||
| lineMessage(); | ||
| return true; | ||
| } | ||
|
|
||
| // Message Functions for cleaner main Function | ||
| public static void lineMessage() { | ||
| String line = "____________________________________________________________\n"; | ||
| System.out.print(line); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the messages, should it be static variables instead and what the methods do is just printing it out? |
||
| public static void helloMessage() { | ||
| String greeting = | ||
| " ._-'-_ .\n" + | ||
| " . ' /_-_-_\\ ` .\n" + | ||
| " .' |-_-_-_-| `.\n" + | ||
| " ( `.-_-_-.' )\n" + | ||
| " !`. .'!\n" + | ||
| " ! ` . . ' !\n" + | ||
| " ! ! ! ! ! ! ! ! !\n" + | ||
| " / / \\ \\\n" + | ||
| " _-| \\___ ___/ /-_\n" + | ||
| " (_ )__\\_)\\(_/__( _)\n" + | ||
| " ))))\\X\\ ((((\n" + | ||
| " \\/ \\/ \n" + | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this logo, it is very cute! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ASCII art rules! 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Love the logo! |
||
| "Hola Amigo, I am Juan Cervantes Salamanca from Michoacan \n" + | ||
| "Welcome to la familia \n" + | ||
| "How can we help you? \n"; | ||
| System.out.print(greeting); | ||
| } | ||
| public static void byeMessage() { | ||
| String bye = "Adios amigo, la familia will miss you\n"; | ||
| System.out.print(bye); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| public class Task { | ||
|
|
||
| // Keep track of tasks | ||
| private static Task[] tasks = new Task[100]; | ||
| private static int taskNumber = 0; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps a better name can be made here, like |
||
|
|
||
| // Object specific variables | ||
| public String taskString; | ||
| public boolean taskDone = false; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the boolean name here be more intuitive like in the Java coding standard? |
||
|
|
||
| // Constructor Function | ||
| public Task(String taskString) { | ||
| this.taskString = taskString; | ||
| tasks[taskNumber] = this; | ||
| taskNumber++; | ||
| System.out.println("Muy Bien, work hard compadre!"); | ||
| System.out.println("I've Added the Task:"); | ||
| System.out.println(taskString); | ||
| } | ||
|
|
||
| // Class mark function | ||
| public static void mark(int taskIndex){ | ||
| if (taskIndex < 0 || taskIndex >= taskNumber){ // Validity Check | ||
| System.out.println("Not possible Amigo, try again"); | ||
| return; | ||
| } | ||
| tasks[taskIndex].taskDone = true; | ||
| System.out.println("Fantastica!!!! I marked it:"); | ||
| System.out.println(tasks[taskIndex].checkboxString()); | ||
| } | ||
|
|
||
| // Class unmark function | ||
| public static void unmark(int taskIndex){ | ||
| if (taskIndex < 0 || taskIndex >= taskNumber){ // Validity Check | ||
| System.out.println("Not possible Amigo, try again"); | ||
| return; | ||
| } | ||
| tasks[taskIndex].taskDone = false; | ||
| System.out.println("Ay Caramba, I unmarked it:"); | ||
| System.out.println(tasks[taskIndex].checkboxString()); | ||
| } | ||
|
|
||
| // Function to create String with Checkbox and Task | ||
| public String checkboxString(){ | ||
| String returnString = "["; | ||
| if (this.taskDone){ | ||
| returnString += "X"; | ||
| } else { | ||
| returnString += " "; | ||
| } | ||
| returnString += "] " + this.taskString; | ||
| return returnString; | ||
| } | ||
|
|
||
| // Function to print out task checklist | ||
| public static void printTasksList(){ | ||
| if (taskNumber == 0){ | ||
| System.out.println("Por Favor? Nothing Here"); | ||
| } else { | ||
| System.out.println("Si compinche, your tasks:"); | ||
| for (int i = 0; i < taskNumber; i++){ | ||
| System.out.println((i+1) + "." + tasks[i].checkboxString()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
Boolean variables/methods should be named to sound like booleans.
The same error is present in other parts of the code.