desislava_topuzakova

02.Articles -> Main

Feb 21st, 2021
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. package Articles_02;
  2.  
  3. import java.util.Locale;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9. String input = scanner.nextLine(); //Title,Content,Author -> ["Title","Content","Author"]
  10. String title = input.split(", ")[0];
  11. String content = input.split(", ")[1];
  12. String author = input.split(", ")[2];
  13.  
  14. Article article = new Article(title, content, author);
  15. int n = Integer.parseInt(scanner.nextLine());
  16.  
  17. for (int i = 0; i < n; i++) {
  18. String command = scanner.nextLine();
  19. //"Edit: {new content}" -> : -> ["Edit", "fsadfsd"]
  20. // "ChangeAuthor: {new author}"
  21. // "Rename: {new title}"
  22. String typeCommand = command.split(": ")[0];
  23. String newData = command.split(": ")[1];
  24.  
  25. switch(typeCommand) {
  26. case "Edit":
  27. article.edit(newData);
  28. break;
  29. case "ChangeAuthor":
  30. article.changeAuthor(newData);
  31. break;
  32. case "Rename":
  33. article.rename(newData);
  34. break;
  35. }
  36. }
  37.  
  38. System.out.println(article);
  39.  
  40. }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment