_MuradPro_

Book

Mar 29th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. public class Book {
  2. String name;
  3. String writer;
  4. int year;
  5. double price;
  6. public Book(String name, String writer, int year, double price) {
  7.     super();
  8.     this.name = name;
  9.     this.writer = writer;
  10.     this.year = year;
  11.     this.price = price;
  12. }
  13. public String getName() {
  14.     return name;
  15. }
  16. public void setName(String name) {
  17.     this.name = name;
  18. }
  19. public String getWriter() {
  20.     return writer;
  21. }
  22. public void setWriter(String writer) {
  23.     this.writer = writer;
  24. }
  25. public int getYear() {
  26.     return year;
  27. }
  28. public void setYear(int year) {
  29.     this.year = year;
  30. }
  31. public double getPrice() {
  32.     return price;
  33. }
  34. public void setPrice(double price) {
  35.     this.price = price;
  36. }
  37.  
  38. public boolean newBook(int year) {
  39.     if(year - this.year <= 3)
  40.         return true;
  41.     else
  42.         return false;
  43. }
  44.  
  45. public double newPrice(double percent) {
  46.     return (double) (this.price += this.price*percent/100);
  47. }
  48. }
Add Comment
Please, Sign In to add comment