Fakultas Ilmu Komputer UI

Commit d414dda4 authored by hazlazuardi's avatar hazlazuardi
Browse files

tmp

parents 2ad8d8a0 b405d28f
rpl,ade01:01:0101:01:01
adpro,daya05:05:0507:07:07
daa,there04:04:0401:01:01
rpl,ade,1:01:01,1:01:02
adpro,daya,5:05:05,7:07:07
daa,there,4:04:04,13:01:01
......@@ -8,5 +8,21 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="opencsv" level="project" />
<orderEntry type="module-library" scope="TEST">
<library name="JUnit5.7.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.7.0/junit-jupiter-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.7.0/junit-jupiter-api-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.7.0/junit-platform-commons-1.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.7.0/junit-jupiter-params-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.7.0/junit-jupiter-engine-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.7.0/junit-platform-engine-1.7.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
admin,ADMIN
st,STUDENT
az,STUDENT
admin,Admin
st,Student
ta,Teaching Assistant
......@@ -3,6 +3,7 @@ package Softeng.Group3.SiJadwal;
import Softeng.Group3.SiJadwal.actor.Role;
import Softeng.Group3.SiJadwal.actor.RoleType;
import Softeng.Group3.SiJadwal.actor.User;
import Softeng.Group3.SiJadwal.repository.CSVOperator;
import Softeng.Group3.SiJadwal.repository.CourseList;
import Softeng.Group3.SiJadwal.repository.UserList;
import Softeng.Group3.SiJadwal.utility.InputReader;
......@@ -93,11 +94,7 @@ public class Main {
public static void main(String[] args) {
userList.addUser("admin", RoleType.ADMIN);
userList.addUser("st", RoleType.STUDENT);
courseList.addCourse("rpl", "ade", Time.valueOf("1:1:1"), Time.valueOf("1:1:1"));
courseList.addCourse("adpro", "daya", Time.valueOf("5:5:5"), Time.valueOf("7:7:7"));
courseList.addCourse("daa", "there", Time.valueOf("4:4:4"), Time.valueOf("1:1:1"));
CSVOperator.InitUsersCourses(userList, courseList);
while (isRunning) {
System.out.println("ON-BOARDING");
......
......@@ -32,6 +32,11 @@ public class Admin extends Role {
System.out.println("===============================");
System.out.println("Course Name?");
courseName = in.next();
for(int i = 0; i < courseList.getCourseList().size(); i++){
if(courseName == courseList.getCourseList().get(i).getCourseName());
System.out.println("Course already exists");
return;
}
System.out.println("Lecturer Name?");
lecturer = in.next();
System.out.println("Start Time? hour:minute:second");
......
......@@ -16,7 +16,7 @@ public enum RoleType {
}
}
public RoleType StringtoRole(String roleType) {
public static RoleType StringtoRole(String roleType) {
switch (roleType){
case "Student":
return STUDENT;
......
......@@ -4,7 +4,34 @@ import java.io.*;
import java.sql.Time;
import java.util.HashMap;
import Softeng.Group3.SiJadwal.actor.RoleType;
public class CSVOperator {
public static void InitUsersCourses(UserList userlist, CourseList courselist){
try{
BufferedReader check = new BufferedReader(new FileReader("Users.csv"));
String row;
while((row = check.readLine()) != null){
String[] users;
users = row.split(",");
userlist.addUser(users[0], RoleType.StringtoRole(users[1]));
}
check.close();
BufferedReader check2 = new BufferedReader(new FileReader("Courses.csv"));
while((row = check2.readLine()) != null){
String[] courses;
courses = row.split(",");
courselist.addCourse(courses[0], courses[1], Time.valueOf(courses[2]), Time.valueOf(courses[3]));
}
check2.close();
}
catch (IOException e) {
System.out.println("File not found.");
e.printStackTrace();
}
}
public static void writeUser(String Uname, String Type) {
try{
FileWriter reader = new FileWriter("Users.csv", true);
......@@ -23,6 +50,7 @@ public class CSVOperator {
check.close();
}
catch (IOException e) {
System.out.println("File not found.");
e.printStackTrace();
}
}
......@@ -39,13 +67,14 @@ public class CSVOperator {
coursesCSV.put(usersWritten[0], usersWritten[1]);
}
if(!coursesCSV.containsKey(name)){
reader.append(name).append(",").append(lecturer)
.append(start.toString()).append(end.toString()).append("\n");
reader.append(name).append(",").append(lecturer).append(",")
.append(start.toString()).append(",").append(end.toString()).append("\n");
}
reader.close();
check.close();
}
catch (IOException e) {
System.out.println("File not found.");
e.printStackTrace();
}
}
......
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