SHARE
TWEET

Untitled

a guest Jun 24th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.Scanner;
  4.  
  5. public class OArticle {
  6.  
  7.     public static class Article {
  8.         String title;
  9.         String content;
  10.         String author;
  11.  
  12.         public Article(String title, String content, String author) {
  13.             this.title = title;
  14.             this.content = content;
  15.             this.author = author;
  16.         }
  17.  
  18.         public String getTitle() {
  19.             return title;
  20.         }
  21.  
  22.         public String getContent() {
  23.             return content;
  24.         }
  25.  
  26.         public String getAuthor() {
  27.             return author;
  28.         }
  29.  
  30.         public String setAuthor() {
  31.             return author;
  32.  
  33.         }
  34.  
  35.         public String setTitle() {
  36.             return title;
  37.  
  38.  
  39.         }
  40.  
  41.         public String setContent() {
  42.             return content;
  43.  
  44.  
  45.         }
  46.  
  47.         public  String toString(){
  48.             return new String("%s-%s: %s");
  49.         }
  50.     }
  51.  
  52.  
  53.         public static void main(String[] args) {
  54.  
  55.         Scanner scanner = new Scanner(System.in);
  56.  
  57.             List<String> articles = new ArrayList<>();
  58.  
  59.             int n = Integer.parseInt(scanner.nextLine());
  60.  
  61.             for (int i = 0; i <= n ; i++) {
  62.  
  63.                 String [] line = scanner.nextLine().split(" ");
  64.                 String title = "";
  65.                 line[0]= title;
  66.                 String content = "";
  67.                 line [1] = content;
  68.                 String author = "";
  69.                 line [2] = author;
  70.  
  71.                 Article article = new Article(title, content, author);
  72.                 articles.add(String.valueOf(article));
  73.  
  74.             }
  75.  
  76.             System.out.printf("%s-%s:%s",articles);
  77.  
  78.  
  79.  
  80.     }
  81.  
  82.  
  83. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top