Faris Alzayed - Task 2 Project#3
Open
FarisAI24 wants to merge 1 commit intoProgramming-Club-IAU:masterfrom
Open
Faris Alzayed - Task 2 Project#3FarisAI24 wants to merge 1 commit intoProgramming-Club-IAU:masterfrom
FarisAI24 wants to merge 1 commit intoProgramming-Club-IAU:masterfrom
Conversation
Radwan-Albahrani
left a comment
There was a problem hiding this comment.
Very good work. This task can now be completed but here are suggested changes that could make the task better.
Comment on lines
81
to
105
| class TaskListApp { | ||
| // TODO: Implement Task list app | ||
| int id; | ||
| String name; | ||
| String description; | ||
| bool isCompleted; | ||
|
|
||
| TaskListApp( | ||
| {required this.id, | ||
| required this.name, | ||
| required this.description, | ||
| this.isCompleted = false}); | ||
|
|
||
| void markAsCompleted() { | ||
| isCompleted = true; | ||
| } | ||
|
|
||
| void markAsIncomplete() { | ||
| isCompleted = false; | ||
| } | ||
|
|
||
| @override | ||
| String toString() { | ||
| return 'Task ID: $id\nTask: $name\nDescription: $description\nCompleted: $isCompleted\n'; | ||
| } | ||
| } |
There was a problem hiding this comment.
I would recommend code separation here. Put it in a different file
Comment on lines
+26
to
+33
| // Add a task | ||
| print('Enter task name:'); | ||
| String name = stdin.readLineSync()!; | ||
| print('Enter task description:'); | ||
| String description = stdin.readLineSync()!; | ||
| tasks.add( | ||
| TaskListApp(id: ++taskId, name: name, description: description)); | ||
| break; |
There was a problem hiding this comment.
Make the cases all functions instead
| print('Enter task description:'); | ||
| String description = stdin.readLineSync()!; | ||
| tasks.add( | ||
| TaskListApp(id: ++taskId, name: name, description: description)); |
There was a problem hiding this comment.
Before adding a task, null check. If i press enter and its empty it shouldnt let me continue
| case '2': | ||
| // Add a task | ||
| print('Enter task name:'); | ||
| String name = stdin.readLineSync()!; |
There was a problem hiding this comment.
Suggested change
| String name = stdin.readLineSync()!; | |
| String name = stdin.readLineSync()!; | |
| if(name.isNotEmpty || name == "") | |
| { | |
| print("Please enter a valid title") | |
| } |
Comment on lines
+36
to
+64
| try { | ||
| print('Enter task ID:'); | ||
| int id = int.parse(stdin.readLineSync()!); | ||
| TaskListApp? taskToUpdate = tasks.firstWhere((task) => task.id == id); | ||
| print('Enter new task name (leave blank to keep current name):'); | ||
| String? name = stdin.readLineSync(); | ||
| print( | ||
| 'Enter new task description (leave blank to keep current description):'); | ||
| String? description = stdin.readLineSync(); | ||
| print( | ||
| 'Would you like to mark this task as completed? (1 for yes, 0 for no)'); | ||
| String? completed = stdin.readLineSync(); | ||
| if (completed == '1') { | ||
| taskToUpdate.markAsCompleted(); | ||
| } | ||
| if (completed == '0') { | ||
| taskToUpdate.markAsIncomplete(); | ||
| } | ||
| if (name != null && name.isNotEmpty) { | ||
| taskToUpdate.name = name; | ||
| } | ||
|
|
||
| if (description != null && description.isNotEmpty) { | ||
| taskToUpdate.description = description; | ||
| } | ||
| } catch (e) { | ||
| print('Task not found, please enter a valid task ID.'); | ||
| } | ||
| break; |
There was a problem hiding this comment.
Same thing, pull to a function instead
| // Remove a task | ||
| print('Enter task ID:'); | ||
| int id = int.parse(stdin.readLineSync()!); | ||
| tasks.removeWhere((task) => task.id == id); |
There was a problem hiding this comment.
very good use of removeWhere. Maybe add a check where if the list is still the same length then ID is wrong
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.