Advertisement
Guest User

Untitled

a guest
Feb 11th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.FileReader;
  3. import java.io.IOException;
  4. import java.util.ArrayList;
  5. import java.util.Scanner;
  6.  
  7. public class Program extends User {
  8.  
  9. public static void main(String[] args) throws IOException {
  10. // TODO Auto-generated method stub
  11.  
  12. ArrayList<Course> newschool = new ArrayList<Course>();
  13. BufferedReader school = null;
  14.  
  15. try {
  16. String filecontents;
  17.  
  18. school = new BufferedReader(new FileReader("/Users/crack/Downloads/MyUniversityCourses.csv"));
  19. while ((filecontents = school.readLine()) != null) {
  20. newschool = (csvconvert(filecontents));
  21. System.out.println(newschool + "\n");
  22. }
  23.  
  24. } catch (IOException e) {
  25. e.printStackTrace();
  26. }
  27.  
  28. Scanner input = new Scanner(System.in);
  29.  
  30. System.out.println("Admin or Student?: ");
  31. String answer = input.nextLine();
  32.  
  33. if (answer.equals("Student")) {
  34. System.out.println("Please enter username: ");
  35. String answer1 = input.nextLine();
  36. System.out.println("Please enter password: ");
  37. String answer2 = input.nextLine();
  38. System.out.println("Please enter first name: ");
  39. String answer3 = input.nextLine();
  40. System.out.println("Please enter last name: ");
  41. String answer4 = input.nextLine();
  42. Student newstudent = new Student(answer1, answer2, answer3, answer4);
  43. System.out.print("1. View all courses" + "\n" + "2. View all courses that are not full" + "\n" +
  44. "3. Register on a course" +
  45. "\n" + "4. Withdraw from a course" + "\n" +
  46. "5. View all courses that you are registered in" + "\n" + "6. Exit");
  47. }
  48.  
  49. if (answer.equals("Admin")) {
  50. System.out.println("Please enter username: ");
  51. String answer1 = input.nextLine();
  52. System.out.println("Please enter password: ");
  53. String answer2 = input.nextLine();
  54. if (answer1.equals("Admin") && answer2.equals("Admin001")) {
  55. Admin newadmin = new Admin("Admin", "Admin001");
  56. System.out.print("1. Create a new course" + "\n" + "2. Delete a course" + "\n" + "3. Edit a course" +
  57. "\n" + "4. Display information for a given course (by course ID)" + "\n" +
  58. "5. Register a student or student’s information" + "\n" + "6. View all courses" + "\n" +
  59. "7. View all courses that are FULL" + "\n" +
  60. "8. Write to a file the list of course that are Full" + "\n" +
  61. "9. View the names of the students being registered in a specific course" + "\n" +
  62. "10. View the list of courses that a given student is being registered on" + "\n" +
  63. "11. Sort courses based on the current number of student registers" + "\n" +
  64. "12. Exit" + "\n");
  65. String answer3 = input.next();
  66. if (answer3.equals("1")) {
  67. System.out.println("Please enter coursename, courseid, maxstud, "
  68. + "currstud, listofnames, teacher, section, and location: ");
  69. String answer4 = input.next();
  70. String answer5 = input.next();
  71. String answer6 = input.next();
  72. String answer7 = input.next();
  73. String answer8 = input.next();
  74. String answer9 = input.next();
  75. String answer10 = input.next();
  76. String answer11 = input.next();
  77. newschool.add(newadmin.newCourse(answer4, answer5, answer6, answer7, answer8,
  78. answer9, answer10, answer11));
  79. System.out.println(newschool);
  80. }
  81. if (answer3.equals("2")) {
  82.  
  83. }
  84.  
  85. if (answer3.equals("3")) {
  86.  
  87. }
  88.  
  89. if (answer3.equals("4")) {
  90.  
  91. }
  92.  
  93. if (answer3.equals("5")) {
  94.  
  95. }
  96.  
  97. if (answer3.equals("6")) {
  98.  
  99. }
  100.  
  101. if (answer3.equals("7")) {
  102.  
  103. }
  104.  
  105. if (answer3.equals("8")) {
  106.  
  107. }
  108.  
  109. if (answer3.equals("9")) {
  110.  
  111. }
  112.  
  113. if (answer3.equals("10")) {
  114.  
  115. }
  116.  
  117. if (answer3.equals("11")) {
  118.  
  119. }
  120.  
  121. if (answer3.equals("12")) {
  122. System.out.println("Goodbye.");
  123. }
  124. }
  125. else
  126. System.out.println("Incorrect username and password.");
  127. }
  128. }
  129.  
  130. public static ArrayList<Course> csvconvert(String filecontents) {
  131.  
  132. ArrayList<Course> schoolarray = new ArrayList<Course>();
  133.  
  134. if (filecontents != null) {
  135.  
  136. String[] splitData = filecontents.split("[\\r\\n]+");
  137.  
  138. for (int i = 0; i < splitData.length; ++i) {
  139. String[] splitRow = splitData[i].trim().split(",");
  140. schoolarray.add(new Course(splitRow[0], splitRow[1], splitRow[2], splitRow[3], splitRow[4], splitRow[5]
  141. , splitRow[6], splitRow[7]));
  142. }
  143. }
  144.  
  145. return schoolarray;
  146. }
  147.  
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement