You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
2.6 KiB
128 lines
2.6 KiB
import 'package:timemanagerapp/setting/Setting.dart';
|
|
|
|
class Course {
|
|
int? id;
|
|
int? userId;
|
|
int courseId;
|
|
String name;
|
|
double credit;
|
|
String teacher;
|
|
String location;
|
|
String remark;
|
|
DateTime start;
|
|
DateTime end;
|
|
|
|
Course({
|
|
this.id,
|
|
required this.userId,
|
|
required this.courseId,
|
|
required this.name,
|
|
required this.credit,
|
|
required this.teacher,
|
|
required this.location,
|
|
required this.remark,
|
|
required this.start,
|
|
required this.end,
|
|
});
|
|
|
|
Map<String,dynamic> toMap(){
|
|
return {
|
|
'userId':userId,
|
|
'courseId':courseId,
|
|
'name':"$name",
|
|
'credit':credit,
|
|
'teacher':"$teacher",
|
|
'location':"$location",
|
|
'remark':"$remark",
|
|
'start':"${start.toIso8601String()}",
|
|
'end':"${end.toIso8601String()}"
|
|
};
|
|
}
|
|
|
|
//初始化任务在周几对应的x坐标
|
|
var weekListPixel=[0,Setting.deviceWidth*0.12,Setting.deviceWidth*0.24,Setting.deviceWidth*0.36,Setting.deviceWidth*0.48,Setting.deviceWidth*0.60,Setting.deviceWidth*0.72];
|
|
// Course(this.name, this.teacher, this.location, this.start, this.end);
|
|
double getdy()
|
|
{
|
|
double y=(((start.hour-7)*60+start.minute)*0.9)*Setting.pixelToMinuteRatio_ratio;
|
|
return y;
|
|
}
|
|
double getdx()
|
|
{
|
|
int x=start.weekday-1;
|
|
return weekListPixel[x].toDouble();
|
|
}
|
|
double getHeight(){
|
|
return (((end.hour-7)*60+end.minute)*0.9-this.getdy())*Setting.pixelToMinuteRatio_ratio;
|
|
}
|
|
|
|
|
|
// Getter methods
|
|
int? get getId => id;
|
|
|
|
int? get getUserId => userId;
|
|
|
|
int get getCourseId => courseId;
|
|
|
|
String get getName => name;
|
|
|
|
double get getCredit => credit;
|
|
|
|
String get getTeacher => teacher;
|
|
|
|
String get getLocation => location;
|
|
|
|
String get getRemark => remark;
|
|
|
|
DateTime get getStart => start;
|
|
|
|
DateTime get getEnd => end;
|
|
|
|
// Setter methods
|
|
set setId(int newId) {
|
|
id = newId;
|
|
}
|
|
|
|
set setUserId(int newUserId) {
|
|
userId = newUserId;
|
|
}
|
|
|
|
set setCourseId(int newCourseId) {
|
|
courseId = newCourseId;
|
|
}
|
|
|
|
set setName(String newName) {
|
|
name = newName;
|
|
}
|
|
|
|
set setCredit(double newCredit) {
|
|
credit = newCredit;
|
|
}
|
|
|
|
set setTeacher(String newTeacher) {
|
|
teacher = newTeacher;
|
|
}
|
|
|
|
set setLocation(String newLocation) {
|
|
location = newLocation;
|
|
}
|
|
|
|
set setRemark(String newRemark) {
|
|
remark = newRemark;
|
|
}
|
|
|
|
set setStart(DateTime newStart) {
|
|
start = newStart;
|
|
}
|
|
|
|
set setEnd(DateTime newEnd) {
|
|
end = newEnd;
|
|
}
|
|
|
|
// toString method
|
|
@override
|
|
String toString() {
|
|
return 'Course(id: $id, userid: $userId, courseId:$courseId, name: $name, credit: $credit, teacher: $teacher, location: $location, remark: $remark, start: $start, end: $end)';
|
|
}
|
|
}
|