Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.*; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; // This class is Admin. in this class admin will provide username and password to Lecturer,Students and

import java.util.*;

import java.io.IOException;

import java.nio.file.Files;

import java.nio.file.Paths;

// This class is Admin. in this class admin will provide username and password to Lecturer,Students and new admins

public class Admin {

public static void main(String[] args) throws IOException {

// for user input...

Scanner input = new Scanner(System.in);

System.out.println("Please choose which information you want to Enter");

System.out.println("1.Enter Lecturers username and password");

System.out.println("2.Enter Students username and password");

System.out.println("3.Enter Admins username and password");

int number = input.nextInt(); // for choosing which user need to add into the system..

while (number != 4) {

// helps for select...

switch (number) {

// case 1 pointing lecturers...

case 1:

LinkedList lec_list = readLecturerFromFile();

System.out.println("How many lecturer Information you want to input");

int value1 = input.nextInt();

if (true) {

for (int i = 0; i < value1; i++) {

System.out.println("Input Lecturer username ");

String name = input.next();

System.out.println("Input Lecturer password");

String password = input.next();

lec_list.add(new Lecturer(name, password)); // helped to add username and password.

System.out.println("Save lecturers to file...");

saveLecturerToFile(lec_list);

}

System.out.println("All lecturers account");

LinkedList lecturers = readLecturerFromFile();

for (int i = 0; i < lecturers.size(); i++)

System.out.println(lecturers.get(i));

System.out.println();

break;

}

case 2:

LinkedList Stu_list = readStudentsFromFile();

System.out.println("How many students username and password you want to input?");

int value2 = input.nextInt();

for (int i = 0; i < value2; i++) {

System.out.println("Input Students Username" );

String name = input.next();

System.out.println("Input Students Password");

String password = input.next();

Stu_list.add(new Students(name, password));// helped to add username and password

System.out.println("Save lecturers to file...");

saveStudentsToFile(Stu_list);

}

System.out.println("All students account");

LinkedList students = readStudentsFromFile();

for (int i = 0; i < students.size(); i++)

System.out.println(students.get(i));

System.out.println();

break;

case 3:

LinkedList nadmin = readAdminFromFile();

System.out.println("How many NewAdmins username and password you want to input?");

int value3 = input.nextInt();

for (int i = 0; i < value3; i++) {

System.out.println("Input Admins Username");

String name = input.next();

System.out.println("Input Admins Password");

String password = input.next();

nadmin.add(new NewAdmins(name, password));

System.out.println("Save admins to file...");

saveAdminToFile(nadmin);

}

System.out.println("All admins account");

LinkedList nadmins = readAdminFromFile();

for (int i = 0; i < nadmins.size(); i++)

System.out.println(nadmins.get(i));

System.out.println();

break;

case 4:

System.out.println("Thank you see you soon");

}

System.out.println();

System.out.println("Please choose which information you want to Enter");

System.out.println("1.Enter Lecturers username and password");

System.out.println("2.Enter Students username and password");

System.out.println("3.Enter Admins username and password");

System.out.println("To exit, press 4");

number = input.nextInt();

}

System.out.println("Exit confirm Thank you ");

}

private static LinkedList readLecturerFromFile() throws IOException {

LinkedList lecturers = new LinkedList<>();

List lines = Files.readAllLines(Paths.get("lecturer.csv"));

for (int i = 0; i < lines.size(); i++) {

String[] items = lines.get(i).split(" ");

lecturers.add(new Lecturer(items[0], items[1]));

}

return lecturers;

}

private static void saveLecturerToFile(LinkedList lecturers) throws IOException {

StringBuilder sb = new StringBuilder();

for (int i = 0; i < lecturers.size(); i++)

sb.append(lecturers.get(i).toCSVString() + " ");

Files.write(Paths.get("lecturer.csv"), sb.toString().getBytes());

}

private static LinkedList readStudentsFromFile() throws IOException {

LinkedList students = new LinkedList<>();

// read students.csv into a list of lines.

List lines = Files.readAllLines(Paths.get("student.csv"));

for (int i = 0; i < lines.size(); i++) {

String[] items = lines.get(i).split(" ");

students.add(new Students(items[0], items[1]));

}

return students;

}

private static void saveStudentsToFile(LinkedList students) throws IOException {

StringBuilder sb = new StringBuilder();

for (int i = 0; i < students.size(); i++)

sb.append(students.get(i).toCSVString() + " ");

Files.write(Paths.get("student.csv"), sb.toString().getBytes());

}

private static LinkedList readAdminFromFile() throws IOException {

LinkedList nadmin = new LinkedList<>();

List lines = Files.readAllLines(Paths.get("admin.csv"));

for (int i = 0; i < lines.size(); i++) {

String[] items = lines.get(i).split(" ");

nadmin.add(new NewAdmins(items[0], items[1]));

}

return nadmin;

}

private static void saveAdminToFile(LinkedList nadmin) throws IOException {

StringBuilder sb = new StringBuilder();

for (int i = 0; i < nadmin.size(); i++)

sb.append(nadmin.get(i).toCSVString() + " ");

Files.write(Paths.get("admin.csv"), sb.toString().getBytes());

}

}

This is my code can you add these two requiremets? 1. Admin can add new projects 2. Admin can delete those projects 3. Admin can leave comments all the projects. After that can you convert the whole code in GUI.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning PostgreSQL On The Cloud Simplifying Database As A Service On Cloud Platforms

Authors: Baji Shaik ,Avinash Vallarapu

1st Edition

1484234464, 978-1484234464

More Books

Students also viewed these Databases questions