Skip to content

Joory Altuwaijri#2

Open
jooryaltuwaijri wants to merge 5 commits intoProgramming-Club-IAU:masterfrom
jooryaltuwaijri:master
Open

Joory Altuwaijri#2
jooryaltuwaijri wants to merge 5 commits intoProgramming-Club-IAU:masterfrom
jooryaltuwaijri:master

Conversation

@jooryaltuwaijri
Copy link

No description provided.

Copy link

@Radwan-Albahrani Radwan-Albahrani left a comment

Choose a reason for hiding this comment

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

Very good work. Fix the above mentioned mistakes and it'll be even better. Also, in your vscode, enable format on save. Your file formatting has a bunch of empty spaces and misaligned brackets and tabs.

new_task.ID = All_tasks.length;

stdout.write('task title: ');
new_task.Title = stdin.readLineSync()!;
Copy link

@Radwan-Albahrani Radwan-Albahrani Oct 1, 2023

Choose a reason for hiding this comment

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

Should add null safety to this

Suggested change
new_task.Title = stdin.readLineSync()!;
String? title = stdin.readLineSync() ?? ""
if(title == "")
{
stdout.write("Title Invalid")
}

Maybe add a while loop or a try catch to keep the user in this state until a title is given

new_task.Title = stdin.readLineSync()!;

stdout.write('task description: ');
new_task.Description = stdin.readLineSync()!;

Choose a reason for hiding this comment

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

Same here

stdout.write('Please enter the ID of the task you want to remove: ');
int task_id = int.parse(stdin.readLineSync()!);

All_tasks.remove(All_tasks[task_id]);

Choose a reason for hiding this comment

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

Check the ID before removing. Could Cause index out of bounds exception

stdout.write('Please enter the ID of the task you want to update: ');
int task_id = int.parse(stdin.readLineSync()!);

Task the_task = All_tasks[task_id];

Choose a reason for hiding this comment

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

Same here

Task the_task = All_tasks[task_id];

stdout.write('What do you want to update (title, description, completed)?');
String? field = stdin.readLineSync()!;

Choose a reason for hiding this comment

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

Null Checking here

stdout.write('Enter new description please: ');
the_task.Description = stdin.readLineSync()!;
}
else if (field == 'competed')

Choose a reason for hiding this comment

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

Mis spelled

@Radwan-Albahrani
Copy link

Seems all things have been resolved. great work!

Copy link

@y0u-0 y0u-0 left a comment

Choose a reason for hiding this comment

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

good job

Comment on lines +4 to +5
List<Task> All_tasks = [];

Copy link

Choose a reason for hiding this comment

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

please read the following https://dart.dev/effective-dart/style for naming in dart.

the variable name should be allTasks

Suggested change
List<Task> All_tasks = [];
List<Task> allTasks = [];

Comment on lines +4 to +20
class Task {

late int ID;
late String Title;
late String Description;
late bool isCompleted;

Task(this.ID, this.Title, this.Description, this.isCompleted);

Task.create() {
ID = 0;
Title = '';
Description = '';
isCompleted = false;
}
}

Copy link

Choose a reason for hiding this comment

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

here you should follow the naming convention for variables.

use "late" only when necessary you could replace it by making constructor required for example:

Suggested change
class Task {
late int ID;
late String Title;
late String Description;
late bool isCompleted;
Task(this.ID, this.Title, this.Description, this.isCompleted);
Task.create() {
ID = 0;
Title = '';
Description = '';
isCompleted = false;
}
}
Task({
required this.id,
required this.title,
required this.description,
required this.isCompleted,
});

you can use factory method too :

Suggested change
class Task {
late int ID;
late String Title;
late String Description;
late bool isCompleted;
Task(this.ID, this.Title, this.Description, this.isCompleted);
Task.create() {
ID = 0;
Title = '';
Description = '';
isCompleted = false;
}
}
factory Task.create() {
return Task(
id: 0,
title: '',
description: '',
isCompleted: false,
);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants