Fakultas Ilmu Komputer UI

Commit bcfcc024 authored by hazlazuardi's avatar hazlazuardi
Browse files

merge with Bagus

parent ea811682
......@@ -48,6 +48,12 @@ public class Main {
System.out.println("===============================");
System.out.println("Username?");
username = in.next();
for (User user : userList.getUserList()) {
if (username.equals(user.getUsername())) {
System.out.println("The user already exists");
return;
}
}
System.out.println("Role?");
System.out.println("1. Student");
System.out.println("2. Teaching Assistant");
......
......@@ -16,6 +16,19 @@ public enum RoleType {
}
}
public RoleType StringtoRole(String roleType) {
switch (roleType){
case "Student":
return STUDENT;
case "Teaching Assistant":
return TEACHING_ASSISTANT;
case "Admin":
return ADMIN;
default:
return null;
}
}
public static RoleType intToRole(int roleIn) {
switch (roleIn) {
case 1: return RoleType.STUDENT;
......
package Softeng.Group3.SiJadwal.repository;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.sql.Time;
import java.util.HashMap;
public class CSVOperator {
public static void writeUser(String Uname, String Type) {
try{
FileWriter reader = new FileWriter("Users.csv", true);
reader.append(Uname).append(",").append(Type).append("\n");
BufferedReader check = new BufferedReader(new FileReader("Users.csv"));
String row;
HashMap<String, String> usersCSV = new HashMap<>();
while((row = check.readLine()) != null){
String[] usersWritten;
usersWritten = row.split(",");
usersCSV.put(usersWritten[0], usersWritten[1]);
}
if(!usersCSV.containsKey(Uname)){
reader.append(Uname).append(",").append(Type).append("\n");
}
reader.close();
check.close();
}
catch (IOException e) {
e.printStackTrace();
......@@ -19,9 +30,20 @@ public class CSVOperator {
public static void writeCourse(String name, String lecturer, Time start, Time end) {
try{
FileWriter reader = new FileWriter("Courses.csv", true);
reader.append(name).append(",").append(lecturer)
.append(start.toString()).append(end.toString()).append("\n");
BufferedReader check = new BufferedReader(new FileReader("Courses.csv"));
String row;
HashMap<String, String> coursesCSV = new HashMap<>();
while((row = check.readLine()) != null){
String[] usersWritten;
usersWritten = row.split(",");
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.close();
check.close();
}
catch (IOException e) {
e.printStackTrace();
......
package Softeng.Group3.SiJadwal.repository;
import Softeng.Group3.SiJadwal.actor.Role;
import Softeng.Group3.SiJadwal.actor.RoleType;
import Softeng.Group3.SiJadwal.actor.User;
......
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