1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
//***************************************************************************
// SPECIFICATION FILE (VideoTape.h)
// This file gives the specification of a VideoTape ADT and provides a
// data type for storing first and last names.
//***************************************************************************
#ifndef VIDEOTAPE_H
#define VIDEOTAPE_H
#include <string>
struct NameType
{
string firstName; // First name
string lastName; // Last name
};
enum RelationType {BEFORE, SAME, AFTER};
const int MAX_STARS = 5; // Maximum number of starring actors
class VideoTape
{
public:
string GetTitle() const;
// Postcondition:
// Function value == title
int GetNumCopies() const;
// Postcondition:
// Function value == numCopies
void GetMovieStars( /* inout */ NameType outStars[] ) const;
// Precondition:
// outStars is assigned
// && outStars is an array of size 5
// Postcondition:
// outStars[0..5] == movieStars[0..5]
NameType GetProducer() const;
// Postcondition:
// Function value == producer
NameType GetDirector() const;
// Postcondition:
// Function value == director
string GetProdCompany() const;
// Postcondition:
// Function value == prodCompany
void AdjustNumCopies( /* in */ int copies );
// Precondition:
// copies is assigned
// Postcondition:
// numCopies += copies
// (to subtract copies, enter a negative value)
bool CheckIfAvailable() const;
// Postcondition:
// Function value == true, if numCopies > 0
// Function value == false, otherwise
void CheckIn();
// Postcondition:
// numCopies == numCopies@call + 1
void CheckOut();
// Precondition:
// CheckIfAvailable == true
// Postcondition:
// numCopies == numCopies@call - 1
RelationType VideoTape::ComparedTo( /* in */ VideoTape otherVideoTape ) const;
// Precondition:
// otherVideoTape is assigned
// Postcondition:
// Function value == BEFORE, if title comes before otherVideoTape's title in the dictionary
// == SAME, if titles are the same
// == AFTER, if title comes after otherVideoTape's title in the dictionary
void PrintTitle() const;
// Postcondition:
// title has been printed
VideoTape( /* in */ string initTitle,
/* in */ int initCopies,
/* in */ NameType initStars[],
/* in */ NameType initProducer,
/* in */ NameType initDirector,
/* in */ string initProdCompany );
// Precondition:
// initTitle, initNumCopies, initStars[], initProducer, initDirector, and initProdCompany are assigned
// && initStars[] is an array of size 5
// Postconidition:
// title == initTitle
// && numCopies == initCopies
// && movieStars[0..5] == initStars[0..5]
// && producer == initProducer
// && director == initDirector
// && prodCompany == initProdCompany
VideoTape(); // Default constructor
// Postcondition:
// title == ""
// && numCopies == 0
// && movieStars[0..5]
// firstName == ""
// lastName == ""
// && producer
// firstName == ""
// lastName == ""
// && director
// firstName == ""
// lastName == ""
// && prodCompany == ""
private:
string title; // Title of movie
int numCopies; // Number of copies
NameType movieStars[MAX_STARS]; // Starring actors
NameType producer; // Producer
NameType director; // Director
string prodCompany; // Production company
};
#endif
|