Advertisement
Guest User

CoursePlanning

a guest
Dec 10th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Collections;
  3. import java.util.List;
  4. import java.util.Scanner;
  5.  
  6. public class SoftUniCoursePlanning {
  7.  
  8. public static void main(String[] args) {
  9. Scanner scanner = new Scanner(System.in);
  10.  
  11. List<String> subjects = new ArrayList<>();
  12.  
  13. String[] scheduleLessons = scanner.nextLine().split(", ");
  14.  
  15. for (String scheduleLesson : scheduleLessons) {
  16. subjects.add(scheduleLesson);
  17. }
  18.  
  19. String line = scanner.nextLine();
  20.  
  21. while(!line.equals("course start")){
  22.  
  23. String[] tokens = line.split(":");
  24. String command = tokens[0];
  25.  
  26. if(command.equals("Add")){
  27. if(!subjects.contains(tokens[1])) {
  28. subjects.add(tokens[1]);
  29. }
  30.  
  31. }else if(command.equals("Insert")){
  32. if(!subjects.contains(tokens[1])) {
  33. subjects.add(Integer.parseInt(tokens[2]), tokens[1]);
  34. // da se vidi indexa
  35. }
  36.  
  37. }else if(command.equals("Remove")){
  38. subjects.remove(tokens[1]);
  39.  
  40.  
  41. }else if(command.equals("Swap")) {
  42.  
  43. if(subjects.contains(tokens[1])&& subjects.contains(tokens[2])){
  44. Collections.swap(subjects, tokens[1].indexOf(tokens[1]),tokens[2].indexOf(tokens[2]));
  45. }
  46.  
  47. }else if(command.equals("Exercise")){
  48. if(subjects.contains(tokens[1])) {
  49.  
  50. }
  51. }
  52.  
  53. line = scanner.nextLine();
  54. }
  55.  
  56. for (int i = 0; i < subjects.size(); i++) {
  57. System.out.println((i+1)+"."+ subjects.get(i));
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement