reyhanzo

Untitled

Dec 17th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. public class Item {
  2.     private String title;
  3.     private int playingtime;
  4.     private boolean gotit;
  5.     private String comment;
  6.     public Item(String title, int playingtime) //constructor
  7.     {
  8.         this.title=title;
  9.         this.playingtime=playingtime;
  10.         this.gotit=false;
  11.         this.comment = "";
  12.     }
  13.     public void setComment(String comment)//method untuk memasukkan comment item
  14.     {
  15.         this.comment = comment;
  16.     }
  17.     public String getComment() //method untuk return comment item
  18.     {
  19.         return this.comment;
  20.     }
  21.     public void setGotIt(boolean gotit) //method untuk memasukkan ketersediaan item
  22.     {
  23.         this.gotit = gotit;
  24.     }
  25.     public boolean getGotIt() //method untuk return ketersediaan item
  26.     {
  27.         return this.gotit;
  28.     }
  29.     public void Print() //method untuk mencetak item
  30.     {
  31.         System.out.println("Title: " + title + "( " + playingtime + " mins )" );
  32.         //cek item tersedia atau tidak
  33.         if(gotit)
  34.         {
  35.             System.out.println("Available");
  36.         }
  37.         else
  38.         {
  39.             System.out.println("Not Available");
  40.         }
  41.         System.out.println(comment);
  42.     }
  43. }
Add Comment
Please, Sign In to add comment