Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Mid 17_Qustn 6 (a)
- public class SongPlayer {
- public static void main(String[] args) {
- Song s1 = new Song("Luis Fonsi", 5.0, "Despasito, bara bara tara tara rara ");
- System.out.println("Song info");
- System.out.println(s1.getInfo());
- System.out.println("Song Lyrics");
- Song.play(s1);
- }
- }
- class Song {
- public String name, lyrics;
- public double duration;
- public Song(String name, double duration, String lyrics) {
- this.name = name;
- this.lyrics = lyrics;
- this.duration = duration;
- }
- public static void play(Song s1){
- System.out.println(s1.lyrics);
- }
- public String getInfo() {
- System.out.printf("Song{Singer Name: %s , duration = %.2f }",name,duration);
- return " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement