This is the version as of February 25th.

public class CDPlayerTest {

    public static void main (String [] args) {
	String beatles1 = new String(
	   "It's been a hard day's night, and I been working like a dog\n" + 
	   "It's been a hard day's night, I should be sleeping like a log\n" +
           "But when I get home to you I'll find the things that you do\n" +
           "Will make me feel alright");
	String beatles2 = new String(
	   "Ah, look at all the lonely people\n" +
	   "Ah, look at all the lonely people\n\n" +
	   "Eleanor Rigby picks up the rice in the church " + 
	   "where a wedding has been\n" + 
	   "Lives in a dream\n" + 
	   "Waits at the window, wearing the face that she keeps " + 
	   "in a jar by the door\n" + 
	   "Who is it for?");
	String beatles3 = new String(
	   "In the town where I was born\n" + 
	   "Lived a man who sailed to sea\n" + 
	   "And he told us of his life\n" + 
	   "In the land of submarines");	
		 
	String thedoors1 = new String(
	   "People are strange when you're a stranger\n" + 
	   "Faces look ugly when you're alone\n" + 
	   "Women seem wicked when you're unwanted\n" + 
	   "Streets are uneven when you're down\n");
	String thedoors2 = new String(
           "Carry me Caravan take me away\n" +
	   "Take me to Portugal, take me to Spain\n" + 
	   "Andalusia with fields full of grain\n" +
	   "I have to see you again and again\n" +
	   "Take me, Spanish Caravan\n" + 
	   "Yes, I know you can");

	String [] songs = new String[3];
	songs[0] = beatles1;
	songs[1] = beatles2;
	songs[2] = beatles3;
	CD beatles = new CD("The Beatles",songs);
	System.out.println(beatles);

	songs = new String[2];
	songs[0] = thedoors1;
	songs[1] = thedoors2;
	CD thedoors = new CD("The Doors",songs);
	System.out.println(thedoors);
	
	CDPlayer myplayer = new CDPlayer();
	myplayer.putCD(beatles);
	myplayer.play(2);
	myplayer.play(2);

	myplayer.putCD(thedoors);
	myplayer.play(2);
    }
}

class CD {
       private String name;
       private String [] songs;
       
       public CD(String name, String [] songs) {
	       	this.name = name;
		this.songs = songs;
       }
    // other methods:

    // toString 
}

class CDPlayer {
       // fill in your code
    // instance variables: cd, song number

    // methods:
    // putCD, play
}


}

This is an example from CSci 1211 course.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.