Advertisement
PetyoKamenov

Untitled

Jul 6th, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3. import java.io.BufferedWriter;
  4. import java.io.FileWriter;
  5. import java.io.IOException;
  6. import java.io.PrintWriter;
  7. import java.util.Date;
  8. import java.text.ParseException;
  9. import java.text.SimpleDateFormat;
  10.  
  11. public class Testtt {
  12. public static void main(String[] args) {
  13. ArrayList<String> ArraynewStudent = new ArrayList<String>();
  14. Scanner input = new Scanner(System.in);
  15. boolean endprogram = false;
  16. while (!endprogram) {
  17. System.out.println("Choice you student status : ");
  18. System.out.println("Press 1 for new student ");
  19. System.out.println("Press 2 for existing student: ");
  20. System.out.println("Press 3 to upload document, certificate or picture: ");
  21. System.out.println("Press 4 to exit program: ");
  22. System.out.println("Press 5 to write student to file: ");
  23. int studentChoice = input.nextInt();
  24. switch (studentChoice) {
  25. case 1:
  26. NewStudent(ArraynewStudent);
  27. break;
  28. case 2:
  29. ActualStudent();
  30. break;
  31. case 3:
  32. CertificateAndProfilePictureOfStudent();
  33. break;
  34. case 4:
  35. endprogram = true;
  36. break;
  37. case 5:
  38. writeStudent("textDataBase\\NewStudent.txt", ArraynewStudent);
  39. break;
  40. }
  41. }
  42. }
  43.  
  44. public static void NewStudent(ArrayList<String> ArrayNewStudent) {
  45. Scanner input = new Scanner(System.in);
  46. // String[] ArrayNewStudent = new String[1];
  47. Date studentDate = new Date();
  48. System.out.print("Enter your names : ");
  49. String studentNames = input.nextLine();
  50. System.out.print("Enter your ID number : ");
  51. String studentId = input.nextLine();
  52. ArrayNewStudent.add(studentNames);
  53. ArrayNewStudent.add(studentId);
  54. ArrayNewStudent.add(studentDate.toString());
  55. for (String newStudent : ArrayNewStudent) {
  56. System.out.println(newStudent);
  57. }
  58. System.out.println();
  59. }
  60.  
  61. public static void CertificateAndProfilePictureOfStudent() {
  62. // качване на сертификати и снимки на студента за портфолиото
  63. }
  64.  
  65. public static void ActualStudent() {
  66. String[] actualStudent = { "Names : Petar Plamenov Kamenov",
  67. "Student ID : 90024242403", "University Number : 09091044 :" };
  68. String[] StudentPayment = { " " };
  69. SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
  70. Date date = new Date();
  71. String StudentEndEducation = "12-09-2016";
  72. Date End = null;
  73. try {
  74. End = format.parse(StudentEndEducation);
  75.  
  76. } catch (ParseException e) {
  77. e.printStackTrace();
  78. }
  79. boolean IsEnded = date.after(End);
  80. if (IsEnded) {
  81. System.out.println("Student is not Active: ");
  82. } else {
  83. System.out.println("Student is Active: ");
  84. }
  85. }
  86.  
  87. public static void StudentsAndExams() {
  88. // опция за признаване на изпит поради издържани майстоски класове
  89. }
  90.  
  91. public static void StudentsAndCertificate() {
  92. // прехвърляне в метода StudentsAndExams(); и признаване на изпитите
  93. }
  94.  
  95. public static void writeStudent(String fileName,
  96. ArrayList<String> ArrayOfStudents) {
  97. try {
  98. PrintWriter writer = new PrintWriter(new BufferedWriter(
  99. new FileWriter(fileName, true)));
  100. String[] simpleStrArray = new String[ArrayOfStudents.size()];
  101. simpleStrArray = ArrayOfStudents.toArray(simpleStrArray);
  102. for (int i = 0; i < ArrayOfStudents.size(); i++) {
  103. writer.println(simpleStrArray[i]);
  104. }
  105. writer.close();
  106. } catch (IOException e) {
  107. e.printStackTrace();
  108. }
  109. }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement