Advertisement
NB52053

// Mid 17_Qustn 6 (a)

Jul 18th, 2017
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. // Mid 17_Qustn 6 (a)
  2.  
  3. public class SongPlayer {
  4.  
  5.     public static void main(String[] args) {
  6.         Song s1 = new Song("Luis Fonsi", 5.0, "Despasito, bara bara tara tara rara ");
  7.  
  8.         System.out.println("Song info");
  9.         System.out.println(s1.getInfo());
  10.         System.out.println("Song Lyrics");
  11.         Song.play(s1);
  12.     }
  13.  
  14. }
  15.     class Song {
  16.  
  17.     public String name, lyrics;
  18.     public double duration;
  19.  
  20.  
  21.      public Song(String name, double duration, String lyrics) {
  22.          this.name = name;
  23.          this.lyrics = lyrics;
  24.          this.duration = duration;
  25.      }
  26.  
  27.         public static void play(Song s1){
  28.  
  29.             System.out.println(s1.lyrics);
  30.         }
  31.  
  32.         public String getInfo() {
  33.  
  34.          System.out.printf("Song{Singer Name: %s , duration = %.2f }",name,duration);
  35.            
  36.          return " ";
  37.      }
  38.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement