-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMusicExchangeTestProgram3.java
More file actions
67 lines (58 loc) · 2.98 KB
/
MusicExchangeTestProgram3.java
File metadata and controls
67 lines (58 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import javafx.util.Pair;
public class MusicExchangeTestProgram3 {
public static void main(String args[]) {
// Create a new music exchange center
MusicExchangeCenter mec = new MusicExchangeCenter();
// Create some users and give them some songs
User discoStew = User.DiscoStew();
User sleepingSam = User.SleepingSam();
User ronnieRocker = User.RonnieRocker();
User countryCandy = User.CountryCandy();
User peterPunk = User.PeterPunk();
// Register the users
discoStew.register(mec);
ronnieRocker.register(mec);
sleepingSam.register(mec);
countryCandy.register(mec);
peterPunk.register(mec);
// Log on all users
discoStew.logon(mec);
sleepingSam.logon(mec);
ronnieRocker.logon(mec);
countryCandy.logon(mec);
peterPunk.logon(mec);
System.out.println("Status: " + mec);
// Simulate users downloading various songs
discoStew.downloadSong(mec, "Bite My Arms Off", "Peter Punk");
discoStew.downloadSong(mec, "Meadows", "Sleeping Sam");
discoStew.downloadSong(mec, "If I Had a Hammer", "Country Candy");
discoStew.downloadSong(mec, "Is that My Toenail ?", "Peter Punk");
sleepingSam.downloadSong(mec, "Anvil Headache", "Peter Punk");
sleepingSam.downloadSong(mec, "Is that My Toenail ?", "Disco Stew");
sleepingSam.downloadSong(mec, "If I Had a Hammer", "Country Candy");
countryCandy.downloadSong(mec, "Anvil Headache", "Peter Punk");
countryCandy.downloadSong(mec, "Meadows", "Sleeping Sam");
countryCandy.downloadSong(mec, "If I Had a Hammer", "Peter Punk");
countryCandy.downloadSong(mec, "Only You Can Rock Me", "Ronnie Rocker");
countryCandy.downloadSong(mec, "Is that My Toenail ?", "Disco Stew");
peterPunk.downloadSong(mec, "Is that My Toenail ?", "Country Candy");
peterPunk.downloadSong(mec, "Rock is Cool", "Ronnie Rocker");
peterPunk.downloadSong(mec, "What?", "Ronnie Rocker");
peterPunk.downloadSong(mec, "Meadows", "Sleeping Sam");
// Display the downloaded songs
System.out.println("\nHere are the downloaded songs: ");
for (Song s: mec.getDownloadedSongs())
System.out.println(s);
// Display the downloaded songs alphabetically
System.out.println("\nHere are the unique downloaded songs alphabetically: ");
for (Song s: mec.uniqueDownloads())
System.out.println(s);
// Display the downloaded songs in order of popularity
System.out.println("\nHere are the downloaded songs by populariry: ");
for (Pair<Integer,Song> p: mec.songsByPopularity())
System.out.println("(" + p.getKey() + " downloads) " + p.getValue());
// Display the royalties
System.out.println("\nHere are the royalties:\n");
mec.displayRoyalties();
}
}