Fakultas Ilmu Komputer UI

Commit af431418 authored by Al Taaj Kautsar Supangkat's avatar Al Taaj Kautsar Supangkat
Browse files

connecting assignment class with another classes

parent b80a35a3
Pipeline #81443 failed with stages
in 14 seconds
st,t1,rpl,adpro,daa
student,mytable,rpl,adpro
student,table,rpl,daa
student,table,rpl,adpro
student,nama,rpl,adpro
student,yes,rpl,adpro
student,yes,rpl,adpro
student,name,rpl,adpro
student,name,rpl,adpro
student,name,rpl,adpro
student,name,rpl,adpro
student,name,rpl,adpro
student,name,rpl,adpro
student,table,rpl,adpro
student,ame,rpl,adpro
student,name,rpl,adpro
student,name,rpl,adpro
student,table,rpl,adpro
student2,table2,rpl
student,name,rpl,adpro
orang,name,rpl,adpro
orang,table,rpl,adpro
......@@ -4,3 +4,6 @@ ta,Teaching Assistant
A,Student
B,Student
C,Student
student,Student
student2,Student
orang,Student
......@@ -2,15 +2,17 @@ package Softeng.Group3.SiJadwal.actor;
import Softeng.Group3.SiJadwal.model.Course;
import Softeng.Group3.SiJadwal.model.Timetable;
import Softeng.Group3.SiJadwal.model.Assignment;
import Softeng.Group3.SiJadwal.repository.CourseList;
import Softeng.Group3.SiJadwal.Main;
import Softeng.Group3.SiJadwal.repository.TimetableList;
import Softeng.Group3.SiJadwal.repository.AssignmentList;
import Softeng.Group3.SiJadwal.repository.UserList;
import java.sql.Time;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
public class Student extends Role {
......@@ -18,8 +20,17 @@ public class Student extends Role {
private HashMap<String, Course> courseOptions;
private CourseList courseList = new CourseList();
private TimetableList timetableList = new TimetableList();
private AssignmentList assignmentList = new AssignmentList();
// User currentUser = Main.currentUser;
private String assignmentName;
private Course assignmentCourse;
private LocalDate dueDate;
private Boolean validated;
private Set<User> validatedBy = new HashSet<>();
private User createdBy;
@Override
public void exclusiveActions() {
System.out.println("6. Create a timetable");
......@@ -27,6 +38,8 @@ public class Student extends Role {
System.out.println("8. Add Course to a timetable");
System.out.println("9. Find a timetable");
System.out.println("10. Delete a timetable");
System.out.println("11. Add an assignment");
System.out.println("12. See the list of assignment");
}
@Override
......@@ -151,6 +164,50 @@ public class Student extends Role {
System.out.println("Timetable deleted.");
break;
case 11:
System.out.println("Add an assignment: ");
System.out.println("===============================");
Assignment assignment = new Assignment();
System.out.println("Assignment Name?");
assignmentName = in.next();
assignment.setAssignmentName(assignmentName);
System.out.println("Pick a course to add assignment: ");
courseList.listToString(courseList.getCourseList());
coursesPicked = in.next().split("");
System.out.println("Picked: ");
for (String s: coursesPicked) {
System.out.println(s + " " + courseList.getCourseList().get(Integer.parseInt(s) - 1).getCourseName());
assignment.setAssignmentCourse(
courseList.getCourseList().get(Integer.parseInt(s) - 1));
}
System.out.println("Enter due date: yyyy-MM-dd");
String date = in.next();
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
dueDate = LocalDate.parse(date);
assignment.setDueDate(dueDate);
assignment.setCreatedBy(Main.currentUser);
assignmentList.addAssignment(assignmentName, assignment);
for (String s: coursesPicked) {
courseList.getCourseList().get(Integer.parseInt(s) - 1).addAssignment(assignment);
}
break;
case 12:
try {
assignmentList.listToString(assignmentList.getAssignmentList());
break;
} catch (NullPointerException e) {
System.out.println("No Assignment");
break;
}
default:
}
}
......
......@@ -55,4 +55,9 @@ public class User {
// }
// }
@Override
public String toString() {
return username;
}
}
......@@ -4,6 +4,7 @@ import Softeng.Group3.SiJadwal.actor.Role;
import Softeng.Group3.SiJadwal.actor.RoleType;
import Softeng.Group3.SiJadwal.actor.User;
import java.time.LocalDate;
import java.util.HashSet;
import java.util.Set;
......@@ -11,6 +12,7 @@ public class Assignment {
private String assignmentName;
private Course assignmentCourse;
private LocalDate dueDate;
private Boolean validated;
private Set<User> validatedBy = new HashSet<>();
private User createdBy;
......@@ -22,6 +24,14 @@ public class Assignment {
public Assignment() {
}
public Assignment(String assignmentName, Course assignmentCourse, LocalDate dueDate, Boolean validated, User createdBy) {
this.assignmentName = assignmentName;
this.assignmentCourse = assignmentCourse;
this.dueDate = dueDate;
this.validated = validated;
this.createdBy = createdBy;
}
public void setAssignmentName(String assignmentName) {
this.assignmentName = assignmentName;
}
......@@ -34,6 +44,10 @@ public class Assignment {
this.assignmentCourse = assignmentCourse;
}
public LocalDate getDueDate() { return dueDate; }
public void setDueDate(LocalDate dueDate) { this.dueDate = dueDate; }
public Boolean getValidated() {
return validationChecker();
}
......@@ -84,4 +98,9 @@ public class Assignment {
return false;
}
@Override
public String toString() {
return "Name: " + assignmentName + " Due Date: " + dueDate + " Created by: " + createdBy;
}
}
package Softeng.Group3.SiJadwal.model;
import java.sql.Time;
import java.util.ArrayList;
import java.util.List;
public class Course {
private String courseName;
private String lecturer;
private Time startTime;
private Time endTime;
private List<Assignment> assignments;
public Course(){};
// public Course(){};
public Course(){ assignments = new ArrayList<>();}
public Course(String courseName, String lecturer, Time startTime, Time endTime) {
this.courseName = courseName;
......@@ -17,6 +23,14 @@ public class Course {
this.endTime = endTime;
}
public Course(String courseName, String lecturer, Time startTime, Time endTime, List<Assignment> assignments) {
this.courseName = courseName;
this.lecturer = lecturer;
this.startTime = startTime;
this.endTime = endTime;
this.assignments = assignments;
}
public String getCourseName() {
return courseName;
}
......@@ -49,8 +63,16 @@ public class Course {
this.endTime = endTime;
}
public List<Assignment> getAssignments() {
return assignments;
}
public void addAssignment(Assignment assignment) {
assignments.add(assignment);
}
@Override
public String toString() {
return "Course: " + courseName + " Start Time: " + startTime + " End Time: " + endTime;
return "Course: " + courseName + " Start Time: " + startTime + " End Time: " + endTime + " Assignments: " + assignments;
}
}
package Softeng.Group3.SiJadwal.repository;
import Softeng.Group3.SiJadwal.actor.User;
import Softeng.Group3.SiJadwal.model.Assignment;
import Softeng.Group3.SiJadwal.model.Course;
import java.sql.Time;
import java.util.ArrayList;
import java.util.List;
public class AssignmentList {
private static List<Assignment> assignmentList = new ArrayList<>();
public List<Assignment> getAssignmentList() {
return assignmentList;
}
public Assignment getAssignment(String assignmentName){
for (Assignment assignment: assignmentList){
if (assignment.getAssignmentName().equalsIgnoreCase(assignmentName)){
return assignment;
}
}
return null;
}
public void addAssignment(String assignmentName, Assignment assignment){
assignmentList.add(assignment);
}
public void listToString(List<Assignment> assignmentList){
int i = 1;
for (Assignment assignment: assignmentList) {
System.out.println(i + ". " + assignment.getAssignmentName());
i++;
}
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment