int
ID is replaced with
a string title.
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 v5
subdirectory.
Driver5.cpp
(that must be
in the DukeDisc
directory). The only difference
between this driver and Driver4.cpp
is that it
must #include
v5 of the DiscChanger
and TextInterface
classes. Specifically:
// THE ORDER MATTERS! #include "v5/DiscChanger.h" #include "v5/TextInterface.h"
Slot
class which
must be in directory v5
. In version 5
you must:
int
ID attribute with a
char *
named title
.title
point to a dynamically allocated
array of 80 char
s. This array must
be allocated in the constructor. The title must be
"Empty" if the Slot
does not contain a disc.
void getID(int &id)
method
with a char *getTitle()
method.
NOTE: This method returns a pointer to a char
array. void setID(int id)
method with a
void setTitle(char *title)
method.
This method must copy the title into the attribute named
title
.DiscChanger
class which
must be in directory v5
. In version 5
you must:
void getID(int &id)
method
with a void getTitle(char *title)
method.
NOTE: This method is passed a pointer to an empty
char
array of size 80. This method should
copy the title of the disc in the current Slot
into this array. (Be Careful: The getTitle()
method in the Slot
class has a different
signature than this method.)void loadDisc(int id)
method with a
void loadDisc(char *title)
method.
strcpy()
function can be used to copy C-style
strings.
makefile
may prove to be useful in this
regard:
# Phony target to build all versions # all: v1 v2 v3 v4 v5 # Phony targets for each version # v1: Driver1 v2: Driver2 v3: Driver3 v4: Driver4 v5: Driver5 # 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 Driver3: Driver3.o v2/TextInterface.o v3/DiscChanger.o v1/Slot.o g++ Driver3.o v2/TextInterface.o v3/DiscChanger.o v1/Slot.o -o Driver3 Driver3.o: Driver3.cpp v2/TextInterface.h v3/DiscChanger.h g++ -c Driver3.cpp Driver4: Driver4.o v2/TextInterface.o v3/DiscChanger.o v1/Slot.o g++ Driver4.o v2/TextInterface.o v3/DiscChanger.o v1/Slot.o -o Driver4 Driver4.o: Driver4.cpp v2/TextInterface.h v3/DiscChanger.h g++ -c Driver4.cpp Driver5: Driver5.o v5/TextInterface.o v5/DiscChanger.o v5/Slot.o g++ Driver5.o v5/TextInterface.o v5/DiscChanger.o v5/Slot.o -o Driver5 Driver5.o: Driver5.cpp v5/TextInterface.h v5/DiscChanger.h g++ -c Driver5.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 # v3 of DiscChanger # v3/DiscChanger.o: v3/DiscChanger.cpp v3/DiscChanger.h v1/Slot.h g++ -c v3/DiscChanger.cpp -o v3/DiscChanger.o # v5 of DiscChanger, Slot and TextInterface # v5/DiscChanger.o: v5/DiscChanger.cpp v5/DiscChanger.h v5/Slot.h g++ -c v5/DiscChanger.cpp -o v5/DiscChanger.o v5/Slot.o: v5/Slot.cpp v5/Slot.h g++ -c v5/Slot.cpp -o v5/Slot.o v5/TextInterface.o: v5/TextInterface.cpp v5/TextInterface.h g++ -c v5/TextInterface.cpp -o v5/TextInterface.o
You can build version 5 of DukeDisc
with the command make v5
.
In these tests, an ID of 1 has been replaced with a title that starts with 'A', an ID of 2 has been replaced with a title that starts with 'B', etc...
Copyright 2010