Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Program extends User {
- public static void main(String[] args) throws IOException {
- // TODO Auto-generated method stub
- ArrayList<Course> newschool = new ArrayList<Course>();
- BufferedReader school = null;
- try {
- String filecontents;
- school = new BufferedReader(new FileReader("/Users/crack/Downloads/MyUniversityCourses.csv"));
- while ((filecontents = school.readLine()) != null) {
- newschool = (csvconvert(filecontents));
- System.out.println(newschool + "\n");
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- Scanner input = new Scanner(System.in);
- System.out.println("Admin or Student?: ");
- String answer = input.nextLine();
- if (answer.equals("Student")) {
- System.out.println("Please enter username: ");
- String answer1 = input.nextLine();
- System.out.println("Please enter password: ");
- String answer2 = input.nextLine();
- System.out.println("Please enter first name: ");
- String answer3 = input.nextLine();
- System.out.println("Please enter last name: ");
- String answer4 = input.nextLine();
- Student newstudent = new Student(answer1, answer2, answer3, answer4);
- System.out.print("1. View all courses" + "\n" + "2. View all courses that are not full" + "\n" +
- "3. Register on a course" +
- "\n" + "4. Withdraw from a course" + "\n" +
- "5. View all courses that you are registered in" + "\n" + "6. Exit");
- }
- if (answer.equals("Admin")) {
- System.out.println("Please enter username: ");
- String answer1 = input.nextLine();
- System.out.println("Please enter password: ");
- String answer2 = input.nextLine();
- if (answer1.equals("Admin") && answer2.equals("Admin001")) {
- Admin newadmin = new Admin("Admin", "Admin001");
- System.out.print("1. Create a new course" + "\n" + "2. Delete a course" + "\n" + "3. Edit a course" +
- "\n" + "4. Display information for a given course (by course ID)" + "\n" +
- "5. Register a student or student’s information" + "\n" + "6. View all courses" + "\n" +
- "7. View all courses that are FULL" + "\n" +
- "8. Write to a file the list of course that are Full" + "\n" +
- "9. View the names of the students being registered in a specific course" + "\n" +
- "10. View the list of courses that a given student is being registered on" + "\n" +
- "11. Sort courses based on the current number of student registers" + "\n" +
- "12. Exit" + "\n");
- String answer3 = input.next();
- if (answer3.equals("1")) {
- System.out.println("Please enter coursename, courseid, maxstud, "
- + "currstud, listofnames, teacher, section, and location: ");
- String answer4 = input.next();
- String answer5 = input.next();
- String answer6 = input.next();
- String answer7 = input.next();
- String answer8 = input.next();
- String answer9 = input.next();
- String answer10 = input.next();
- String answer11 = input.next();
- newschool.add(newadmin.newCourse(answer4, answer5, answer6, answer7, answer8,
- answer9, answer10, answer11));
- System.out.println(newschool);
- }
- if (answer3.equals("2")) {
- }
- if (answer3.equals("3")) {
- }
- if (answer3.equals("4")) {
- }
- if (answer3.equals("5")) {
- }
- if (answer3.equals("6")) {
- }
- if (answer3.equals("7")) {
- }
- if (answer3.equals("8")) {
- }
- if (answer3.equals("9")) {
- }
- if (answer3.equals("10")) {
- }
- if (answer3.equals("11")) {
- }
- if (answer3.equals("12")) {
- System.out.println("Goodbye.");
- }
- }
- else
- System.out.println("Incorrect username and password.");
- }
- }
- public static ArrayList<Course> csvconvert(String filecontents) {
- ArrayList<Course> schoolarray = new ArrayList<Course>();
- if (filecontents != null) {
- String[] splitData = filecontents.split("[\\r\\n]+");
- for (int i = 0; i < splitData.length; ++i) {
- String[] splitRow = splitData[i].trim().split(",");
- schoolarray.add(new Course(splitRow[0], splitRow[1], splitRow[2], splitRow[3], splitRow[4], splitRow[5]
- , splitRow[6], splitRow[7]));
- }
- }
- return schoolarray;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement