MusicShop

MusicShop - /* * File: MusicShop.java * -* This program...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * File: MusicShop.java * -------------------- * This program handles the data management for a music * shop, showing which albums are sold and how many copies * are in stock. The program handles dynamic resizing of * the program window. */ import acm.program.*; import acm.util.*; import java.awt.event.*; import java.io.*; import java.util.*; import javax.swing.*; public class MusicShop extends Program { // Set up initial display with interactors and canvas public void init() { label = new JLabel("Album Name"); albumName = new JTextField(20); add(label, SOUTH); add(albumName, SOUTH); loadInventory(); canvas = new MusicShopDisplay(); add(canvas); albumName.addActionListener(this); } // Read file to get inventory information on all albums private void loadInventory() { try { BufferedReader rd = new BufferedReader( new FileReader("music-data.txt")); while (true) { String line = rd.readLine(); if (line == null) break; Album album = parseLine(line); inventory.put(album.getAlbumName(), album);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

MusicShop - /* * File: MusicShop.java * -* This program...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online