Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- public class Main {
- static class Article {
- private String title;
- private String content;
- private String autor;
- public Article(String title, String content, String autor) {
- this.title = title;
- this.content = content;
- this.autor = autor;
- }
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- public String getContent() {
- return content;
- }
- public void setContent(String content) {
- this.content = content;
- }
- public String getAutor() {
- return autor;
- }
- public void setAutor(String autor) {
- this.autor = autor;
- }
- @Override
- public String toString() {
- return String.format("%s - %s: %s", getTitle(), getContent(), getAutor());
- }
- }
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String line = scanner.nextLine();
- String[] tokens = line.split(", ");
- String title = tokens[0];
- String content = tokens[1];
- String autor = tokens[2];
- Article article = new Article(title, content, autor);
- int n = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i < n; i++) {
- String command = scanner.nextLine();
- if (command.contains("Edit")) {
- String[] input = command.split(": ");
- String newContent = input[1];
- article.setContent(newContent);
- } else if (command.contains("ChangeAuthor")) {
- String[] input = command.split(": ");
- String newAutor = input[1];
- article.setAutor(newAutor);
- } else if (command.contains("Rename")) {
- String[] input = command.split(": ");
- String newTitle = input[1];
- article.setTitle(newTitle);
- }
- }
- System.out.println(article);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement