Question Two
- In the first task, it is necessary to model the classes and interfaces that are necessary to describe the simplified model of the music industry. Various bands (Band) are featured at concerts or festivals (Festival), which are characterized by their name and the members, or musicians (Musician).
The code below needs to be updated to allow for the full functionality of the Main class, provided below. Assume that all getters and setters (for those variables that can be changed) are already written and you do not need to write them, and that the equals methods are overridden where they need to be.
NOTE: The task should use the superclass constructor whenever possible, and respect the good practice of the object- oriented paradigm.
public class
Main {
public static void
main(String[] args) {
Musician m1 =
new
Musician("Dave Grohl", "USA", 50, BandPosition.
SINGER
, 98);
Musician m2 =
new
Musician("Pat Smear", "USA", 59, BandPosition.
GUITARIST
, 85);
Musician m3 =
new
Musician("Chris Shiflett", "USA", 47, BandPosition.
GUITARIST
, 85);
Musician m4 =
new
Musician("Nate Mendel", "USA", 50, BandPosition.
BASSIST
, 93);
Musician m5 =
new
Musician("Taylor Hawkins", "USA", 47, BandPosition.
SINGER
, 70);
Musician m6 =
new
Musician("Rami Jaffee", "USA", 50, BandPosition.
PIANIST
, 72);
Musician[] musicians1 =
new
Musician[] {m1,m2,m3,m4,m5,m6}; Band b1 =
new
Band(musicians1, "Foo Fighters");
Manager manager =
new
Manager("Steven Howard", "USA", 67, b1); System.
out
.println(b1);
manager.kickBandMember(m6); System.
out
.println(b1);
System.
out
.println("Band member " + m3.getName() + " before training: "
+ "Age: " + m3.getAge() + " Skill: " + m3.getSkill()); m3.trainForOneYear();
System.
out
.println("Band member " + m3.getName() + " after training: "
+ "Age: " + m3.getAge() + " Skill: " + m3.getSkill()); Event c1 =
new
Concert("PulaConcert", "Croatia", "19 June",
b1,
new
String[] {"Best of You", "My Hero", "Big Me"});
System.
out
.println("----CONCERT POSTER ");
((EventPromoter) c1).printEventPoster();
Musician m7 =
new
Musician("Dan Auerbach", "USA", 39, BandPosition.
SINGER
, 98);
Musician m8 =
new
Musician("Patrick James Carney", "USA", 38, BandPosition.
DRUMMER
, 97);
Musician[] musicians2 =
new
Musician[] {m7, m8}; Band b2 =
new
Band(musicians2, "The Black Keys"); Person m9 =
new
Musician("Jack Black", "USA", 49, BandPosition.
SINGER
, 100);
Person m10 =
new
Musician("Kyle Gass", "USA", 58, BandPosition.
GUITARIST
, 100);
Person p1 =
new
Person("Goran Bare", "Croatia", 53);
Band b3 =
new
Band(new
Musician[] {(Musician) m9, (Musician) m10}, "Tenacious D");
Band[] bands =
new
Band[] {b1, b2, b3};
Event f1 =
new
Festival("Rock in Croatia", "Zagreb", "5 June", bands);
System.
out
.println("----FESTIVAL POSTER---- ");
((EventPromoter) f1).printEventPoster();
}
}
PRINT
Members of the band Foo Fighters are: Dave Grohl, Pat Smear, Chris Shiflett, Nate Mendel, Taylor Hawkins, Rami Jaffee
Members of the band Foo Fighters are: Dave Grohl, Pat Smear, Chris Shiflett, Nate Mendel, Taylor Hawkins
Band member Chris Shiflett before training: Age: 47 Skill: 85 Band member Chris Shiflett after training: Age: 48 Skill: 86
----CONCERT POSTER----
Event date: 19 June Band: Foo Fighters
Song list for this concert is: Song 1: Best of You
Song 2: My Hero Song 3: Big Me
Event date: 5 June Festival: Rock in Croatia Band list for the festival is: Band 1: Foo Fighters
Band 2: The Black Keys Band 3: Tenacious D
----FESTIVAL POSTER----
Each musician in a band has a role (BandPosition) that is defined by the finite set of roles and a certain level of skill for that role. Furthermore, every musician through his career can progress through training by increasing his skill by one year (obviously becoming older by one year). Each member of the band, in addition to their role and their associated skills, has the following values: their name, their country of origin and a certain number of years. In the music industry, apart from musicians, there is a very important entity of Manager. Like the musician, he has his name, his country of origin and his number of years. In addition to the above characteristics, the manager can eject one of the band members (must be implemented in such a way that the band member field is reduced and the corresponding member ejected - the length of the field must correspond to the number of band members; it is not necessary to check that the band member is in the field, you can assume that Is placed). Ensure that objects instantiated from the Band class can be printed as described in the main method.
public
Person {
private final
String name;
private final
String country;
private int
age;
}
public enum
BandPosition {
SINGER
,
GUITARIST
,
BASSIST
,
DRUMMER
,
PIANIST
}
public
Musician{
private
Integer skill;
private
BandPosition bandPosition;
public void
trainForOneYear() {
}
}
public
Band {
private
Musician[] bandMembers;
private
String bandName;
}
public
Manager{
private
Band managingBand;
public void
kickBandMember(Musician musician) {
}
}
Extracted text: As part of this simplified model, we have defined two events (Event, non-instantiable class): a concert and a festival. Both events have the name, location, and date attributes. The concert as an event is defined by the band performing and the list of songs that the band performs, while the festival is defined by the list of bands performing at that festival. Both events have poster printing functionality specified by the EventPromoter interface. The poster for the concert contains information about the date of the event, the band performing, and a list of songs, while the poster for the festival contains the date of the event, the name of the festival, and a list of the bands performing at that festival. public private final String name; Event { private final String location; private String date; } public interface EventPromoter { public void printEventPoster(); } public private Band[] bandList; } Festival public private Band plavingband; private String[] songlist; } b) Two musicians (exclusively musicians) can also compare each other by their skill (assume that each position in the band is valued equally, eg a guitarist with skill 100 is equal to a singer with skill 100). Write a SkillComparator class that implements the specified functionality through the Comparator
interface. Concert_ public SkillComparator