View difference between Paste ID: sbWHe3TP and vcUQA9PP
SHOW: | | - or go back to the newest paste.
1
import java.util.Scanner;
2
3
public class main{
4
    public static void main(String[] args) {
5
        Scanner sc = new Scanner(System.in);
6
7
        String[] arr = sc.nextLine().split(",\\s+");
8
        int n = Integer.parseInt(sc.nextLine());
9
10
        Article article = new Article(arr[0], arr[1], arr[2]);
11
12
        for (int i = 0; i < n; i++) {
13
            arr = sc.nextLine().split(": ");
14
15
            switch (arr[0]){
16
                case "Edit":
17
                    article.edit(arr[1]);
18
                    break;
19
20
                case "ChangeAuthor":
21
                    article.changeAuthor(arr[1]);
22
                    break;
23
24
                case "Rename":
25
                    article.rename(arr[1]);
26
                    break;
27
            }
28
        }
29
30
        System.out.println(article.toString());
31
    }
32
33
    public static class Article {
34
        private String title;
35
        private String content;
36
        private String author;
37
38
        public Article(String title, String content, String author){
39
            this.author = author;
40
            this.content = content;
41
            this.title = title;
42
        }
43
44
        public void edit(String content){
45
            this.content = content;
46
        }
47
48
        public void changeAuthor(String author){
49
            this.author = author;
50
        }
51
52
        public void rename(String title){
53
            this.title = title;
54
        }
55
56
        @Override
57
        public String toString(){
58
            String result = String.format("%s - %s: %s",
59
                    this.title, this.content, this.author);
60
            return result;
61
        }
62
    }
63
64
}