Exercise 1: Guitar Hero
Transcription
Exercise 1: Guitar Hero
Exercise 1: Guitar Hero The upcoming Guitar Hero XIII: Legends of Rock needs a player configuration system. Guitar Hero XIII lets you play three different characters (Slash, Jimi Hendrix, and Angus Young). Each character can play one of three available guitars (Gibson SG, Fender Telecaster or Gibson Les Paul) and perform a unique solo act (Put the Guitar on Fire, Jump off stage, Smash the Guitar). character guitar solo act Slash (Guns Roses) Gibson Les Paul Smash the Guitar Jimi Hendrix Fender Telecaster Guitar on fire Angus Young (AC/DC) Gibson SG Jump off stage Assignment 1: Implement a player configuration system in Java using the Strategy design pattern. Here’s a class containing the Java Main method to help you on your way. public class GuitarHero { public static void main(String[] args) { GameCharacter player1 = new GameCharacterSlash(); GameCharacter player2 = new GameCharacterHendrix(); player1.playGuitar(); player2.playGuitar(); player1.playSolo(); player2.playSolo(); } } Hint1: Use the Java Duck example from Chapter 1. Assignment 2: Some guitar players trash their guitars on stage. Modify your code so players can change guitars on the fly. Assignment 3: Try to draw a class diagram for your solution using violetUML. Identify the IS-A, HAS-A and IMPLEMENTS relationships.