Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Book {
- String author;
- String title;
- int year;
- void setAuthor(String author)
- {
- this.author=author;
- }
- void setTitle(String title)
- {
- this.title=title;
- }
- void setYear(int year)
- {
- this.year=year;
- }
- public String getAuthor()
- {
- return author;
- }
- public String getTitle()
- {
- return title;
- }
- public int getYear()
- {
- return year;
- }
- }
- class BookTest
- {
- public static void main(String[] args)
- {
- Scanner sc=new Scanner(System.in);
- Book poem=new Book();
- System.out.println("Input: ");
- String author=sc.next();
- String title=sc.next();
- int year=sc.nextInt();
- poem.setAuthor(author);
- poem.setTitle(title);
- poem.setYear(year);
- System.out.println(poem.getAuthor());
- System.out.println(poem.getTitle());
- System.out.println(poem.getYear());
- }
- }
Add Comment
Please, Sign In to add comment