Fakultas Ilmu Komputer UI

Commit ad1e5d07 authored by Bagus Prabowo's avatar Bagus Prabowo
Browse files

Branch fix

parents 61f6dba0 a83b6d2a
Pipeline #81524 failed with stages
in 13 seconds
image: java:latest
stages:
- build
- execute
build:
stage: build
script: /usr/lib/jvm/java-8-openjdk-amd64/bin/javac Main.java
artifacts:
paths:
- Main.*
execute:
stage: execute
script: /usr/lib/jvm/java-8-openjdk-amd64/bin/java Main
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
student,name,rpl,adpro
orang,name,rpl,adpro
student,name,rpl,adpro
\ No newline at end of file
admin,Admin
st,Student
ta,Teaching Assistant
A,Student
B,Student
C,Student
student,Student
student2,Student
orang,Student
stages:
- build
- test
image: gradle:6.1.1-jdk8
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
build:
stage: build
script:
- gradle assemble --parallel
test:
stage: test
script:
- gradle check --parallel
- gradle jacocoTestReport --parallel
- gradle jacocoTestCoverageVerification
- gradle jacocoMergeTest
artifacts:
paths:
- build/jacoco/allTestCoverage.exec
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- $GRADLE_USER_HOME/wrapper
- $GRADLE_USER_HOME/caches
Manifest-Version: 1.0
Main-Class: Softeng.Group3.SiJadwal.Main
Manifest-Version: 1.0
Main-Class: Softeng.Group3.SiJadwal.Main
......@@ -2,13 +2,24 @@ 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;
<<<<<<< HEAD
import Softeng.Group3.SiJadwal.repository.CSVTimetable;
import java.util.HashMap;
import java.util.List;
=======
import Softeng.Group3.SiJadwal.repository.AssignmentList;
import Softeng.Group3.SiJadwal.repository.UserList;
import java.sql.Time;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
>>>>>>> a83b6d2a211d37b5a85e663de2aaacea9a35b505
public class Student extends Role {
......@@ -16,16 +27,35 @@ 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;
<<<<<<< HEAD
=======
private String assignmentName;
private Course assignmentCourse;
private LocalDate dueDate;
private Boolean validated;
private Set<User> validatedBy = new HashSet<>();
private User createdBy;
>>>>>>> a83b6d2a211d37b5a85e663de2aaacea9a35b505
@Override
public void exclusiveActions() {
System.out.println("6. Create a timetable");
System.out.println("7. See the list of timetable");
System.out.println("8. Add Course to a timetable");
<<<<<<< HEAD
System.out.println("9. Delete a Course in a timetable");
System.out.println("10. Find a timetable");
System.out.println("11. Delete 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");
>>>>>>> a83b6d2a211d37b5a85e663de2aaacea9a35b505
}
@Override
......@@ -197,6 +227,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;
}
}
package Softeng.Group3.SiJadwal.model;
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;
public class Assignment {
private String assignmentName;
private Course assignmentCourse;
private LocalDate dueDate;
private Boolean validated;
private Set<User> validatedBy = new HashSet<>();
private User createdBy;
public String getAssignmentName() {
return assignmentName;
}
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;
}
public Course getAssignmentCourse() {
return assignmentCourse;
}
public void setAssignmentCourse(Course assignmentCourse) {
this.assignmentCourse = assignmentCourse;
}
public LocalDate getDueDate() { return dueDate; }
public void setDueDate(LocalDate dueDate) { this.dueDate = dueDate; }
public Boolean getValidated() {
return validationChecker();
}
public void setValidated(Boolean customValidated) {
this.validated = customValidated;
}
public Set<User> getValidatedBy() {
return validatedBy;
}
public void addValidatedBy(User user) {
this.validatedBy.add(user);
}
public void removeValidatedBy(User user) {
this.validatedBy.remove(user);
}
public void clearValidatedBy() {
this.validatedBy.clear();
}
public User getCreatedBy() {
return createdBy;
}
public void setCreatedBy(User createdBy) {
this.createdBy = createdBy;
}
private Boolean validationChecker() {
Set<User> bucket = new HashSet<>();
for (User u: this.validatedBy) {
if (u.getRole().getRoleName().equals(RoleType.STUDENT)) {
bucket.add(u);
}
if (u.getRole().getRoleName().equals(RoleType.TEACHING_ASSISTANT)) {
setValidated(true);
return true;
}
}
if (bucket.size() >= 3 ) {
setValidated(true);
return true;
}
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 "\nCourse: " + courseName + ", Start Time: " + startTime + ", End Time: " + endTime + "\nAssignments: " + 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
package test;
import Softeng.Group3.SiJadwal.actor.*;
import Softeng.Group3.SiJadwal.model.Assignment;
import Softeng.Group3.SiJadwal.model.Course;
import Softeng.Group3.SiJadwal.repository.UserList;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import java.sql.Time;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.*;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class AssignmentTest {
private final static UserList userList = new UserList();
@Test
void testIfThereAreThreeStudentInValidatedBy() {
User a = new User();
Role r = new Student();
r.setRoleName(RoleType.STUDENT);
Assignment assignment = new Assignment();
a.setUsername("A");
a.setRole(r.getRoleName());
userList.addUser(a.getUsername(), a.getRole().getRoleName());
User b = new User("B", r);
userList.addUser(b.getUsername(), b.getRole().getRoleName());
User c = new User("C", r);
userList.addUser(c.getUsername(), c.getRole().getRoleName());
Set<User> vdum = assignment.getValidatedBy();
assertEquals(0, vdum.size());
assignment.addValidatedBy(a);
assignment.addValidatedBy(b);
assignment.addValidatedBy(c);
assertEquals(3, vdum.size());
assertEquals(true, assignment.getValidated());
}
@Test
void testIfThereIsATeachingAssistantInValidatedBy() {
Role rt = new TeachingAssistant();
User t = new User("TA", rt);
rt.setRoleName(RoleType.TEACHING_ASSISTANT);
Assignment assignmentT = new Assignment();
assertEquals(0, assignmentT.getValidatedBy().size());
assignmentT.addValidatedBy(t);
assertEquals(1, assignmentT.getValidatedBy().size());
assertEquals(true, assignmentT.getValidated());
assignmentT.clearValidatedBy();
assertEquals(0, assignmentT.getValidatedBy().size());
}
@Test
void getAssignmentName() {
Assignment assignment = new Assignment();
assertNull(assignment.getAssignmentName());
}
@Test
void setAssignmentName() {
Assignment assignment = new Assignment();
assignment.setAssignmentName("Practical 10");
assertEquals("Practical 10", assignment.getAssignmentName());
}
@Test
void getAssignmentCourse() {
Assignment assignment = new Assignment();
assertNull(assignment.getAssignmentCourse());
}
@Test
void setAssignmentCourse() {
Assignment assignment = new Assignment();
Course rpl = new Course("RPL", "Ade", new Time(500), new Time(1000));
assignment.setAssignmentCourse(rpl);
assertEquals(rpl, assignment.getAssignmentCourse());
}
@Test
void getValidated() {
Assignment assignment = new Assignment();
assertEquals(false, assignment.getValidated());
}
@Test
void setValidated() {
Assignment assignment = new Assignment();
assignment.setValidated(true);
assertNotNull(assignment.getValidated());
}
@Test
void addValidatedBy() {
Assignment assignment = new Assignment();
User toAdd = new User();
assignment.addValidatedBy(toAdd);
assertEquals(1, assignment.getValidatedBy().size());
assertEquals(true, assignment.getValidatedBy().contains(toAdd));
}
@Test
void getValidatedBy() {
Assignment assignment = new Assignment();
assertEquals(0, assignment.getValidatedBy().size());
}
@Test
void removeValidatedBy() {
Assignment assignment = new Assignment();
User toRemove = new User();
assignment.addValidatedBy(toRemove);
assertEquals(1, assignment.getValidatedBy().size());
assignment.removeValidatedBy(toRemove);
assertEquals(false, assignment.getValidatedBy().contains(toRemove));
}
@Test
void clearValidatedBy() {
Assignment assignment = new Assignment();
assignment.addValidatedBy(new User());
assertEquals(1, assignment.getValidatedBy().size());
assignment.clearValidatedBy();
assertEquals(0, assignment.getValidatedBy().size());
}
@Test
void getCreatedBy() {
}
@Test
void setCreatedBy() {
}
}
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