JMU
../DukeDisc.gif
DukeDisc v2


Background
Existing Components
The TextInterface class has already been implemented. The source code is available but must not be modified (though you may #include additional libraries if necessary).

TextInterface ( Header , Implementation )

This class must be in the v2 subdirectory.

New Code:
The Driver: You must write a driver named Driver2.cpp (that must be in the DukeDisc directory). The driver must:
  1. Declare a pointer to a DiscChanger.
  2. Declare a pointer to a TextInterface.
  3. Construct a DiscChanger object using dynamically allocated memory.
  4. Construct a TextInterface object using dynamically allocated memory, passing the constructer the pointer to the DiscChanger and either the value true (for verbose mode) or false (for terse mode).
  5. Call the TextInterface object's start() method.

Since the driver uses both the DiscChanger and TextInterface classes it must #include the appropriate header files. In this case it must #include both v2/TextInterface.h and v1/DiscChanger.h.

Other Issues:
Building: The following makefile may prove to be useful in this regard:
# Phony target to build all versions
#
all: v1 v2

# Phony targets for each version
#
v1: Driver1
v2: Driver2



# Drivers
#
Driver1: Driver1.o v1/DiscChanger.o v1/Slot.o
	g++ Driver1.o v1/DiscChanger.o v1/Slot.o -o Driver1

Driver1.o:  Driver1.cpp v1/DiscChanger.h
	g++ -c Driver1.cpp

Driver2: Driver2.o v2/TextInterface.o v1/DiscChanger.o v1/Slot.o
	g++ Driver2.o v2/TextInterface.o v1/DiscChanger.o v1/Slot.o -o Driver2

Driver2.o:  Driver2.cpp v2/TextInterface.h v1/DiscChanger.h 
	g++ -c Driver2.cpp



# v1 of DiscChanger and Slot
#
v1/DiscChanger.o: v1/DiscChanger.cpp v1/DiscChanger.h v1/Slot.h
	g++ -c v1/DiscChanger.cpp -o v1/DiscChanger.o

v1/Slot.o: v1/Slot.cpp v1/Slot.h
	g++ -c v1/Slot.cpp  -o v1/Slot.o



# v2 of TextInterface
#
v2/TextInterface.o: v2/TextInterface.cpp v2/TextInterface.h
	g++ -c v2/TextInterface.cpp -o v2/TextInterface.o

  

You can build version 2 of DukeDisc with the command make v2.

Testing: You can use the same tests you used for v1.

Copyright 2010