desislava_topuzakova

Article

Feb 21st, 2021
978
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. package Articles_02;
  2.  
  3. public class Article {
  4.     //fields
  5.     private String title;
  6.     private String content;
  7.     private String author;
  8.  
  9.     //constructor
  10.     public Article(String title, String content, String author) {
  11.         this.title = title;
  12.         this.content = content;
  13.         this.author = author;
  14.     }
  15.  
  16.     //methods
  17.     public void edit(String newContent) {
  18.         this.content = newContent;
  19.     }
  20.  
  21.  
  22.     public void changeAuthor (String newAuthor) {
  23.         this.author = newAuthor;
  24.     }
  25.  
  26.     public void rename (String newTitle) {
  27.         this.title = newTitle;
  28.     }
  29.  
  30.  
  31.    @Override
  32.     public String toString() {
  33.         //обект -> текст
  34.         //"{title} - {content}:{author}"
  35.         return title + " - " + content + ": " + author;
  36.     }
  37.  
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment