Lecture 7 Objectives


At the end of today's class you should

KNOW:

BE ABLE TO:

Sample Exam Question:

A program defines a class Song:

class Song{
  String title;
  String artist;
  int price;

  Song(String title, String artist, int price){
    this.title = title;
    this.artist = artist;
    this.price = price;
  }
}
and a class Playlist:
class Playlist{
  LinkedList<Song> songs;

  PlayList(){
     this.songs = new LinkedList<Song>();
  }

  // add a song to this playlist
  void addSong(Song s){
    this.songs.add(s);
  }
}
Write a method increasePrice in the Playlist class that increases the price of every song in the playlist by $1.