Let's revisit the ticket-site example that was mentioned in Exercise 2.1. Here's the specification again.
A client can visit the server and search a schedule for a concert. A concert specifies a performer, a venue and a date. After selecting a concert, the client sees a list of some available tickets, specifying seat and price. The client can view a map to see where the seats are located. The client can select tickets and add them to his or her order. The client can buy the order by filling in an address form and giving credit card information.
Figure out a set of classes based on some or all of the nouns in the description and arrange them into a UML diagram. Test the completeness of your diagram by tracing some use cases through it. Draw the diagram at least three times, improving it each time.
A couple of years ago the music-sharing site called Napster ran a 'share-server' that satisfied the following specification. A client can log into the share-server. The share-server maintains a 'share pair list' of 'share pairs,' where a share pair consists of a song name and a link to a client who has this song available. When a client logs in, the share-server adds share pairs for the client's songs to the share pair list. A client can request a song, and the share-server displays a sublist of the share pair list showing share pairs for that song. If a client selects a share pair, the song is transferred to this client from the client mentioned in the share pair.
Figure out a set of classes based on some or all of the nouns in the description and arrange them into a UML diagram. The diagram will primarily have composition lines connecting the boxes. Test the completeness of your diagram by tracing some use cases through it. Draw the diagram at least three times, improving it each time.
Napster was successfully sued by the record companies for maintaining a share-server like this. In 2001 a possibly legal work-around emerged. Companies like KaZaA added another layer to the architecture. Rather than maintaining a share-server, they maintain a meta-server which directs clients to other client machines that are acting as share-servers.
Show how to add a meta-server to the UML diagram you got in the last exercise.
Write a few lines of code to implement a utility container cCritterPair class to hold two cCritter * pointers as private members. The class should have a constructor that takes a pair of pointers as arguments and two accessors to get at the member pointers. Don't bother with mutators. Assume that cCritterPair should not delete its members in its destructor.
Here we make some changes to the initializations of the static variables in gamespacewar.cpp and see what happens. When you change a static, it's usually wise to leave the original value as a comment to the right so you can get it back if necessary.
Increase cGameSpacewar::WORLDSIZE and notice how much bigger the world gets relative to the critters.
Increase cCritterAsteroid::DARTACCELERATION and cCritterAsteroid: :DARTSPEEDUP and notice that it becomes nearly impossible to shoot an asteroid.
Change cGameSpacewar::ASTEROIDHEALTH to four and notice how many times you have to shoot and split up an asteroid before finally getting rid of it.
Draw two pictures to represent the inheritance and composition relationships shown in Figure 4.8, but have your pictures represent classes by egg-shaped images as were used in Figure 4.5.