// Assg5.cpp - driver program for multiple base class derived // derived classes. // // Will England // March 3, 1999 // Programming 2 #include #include #include "package.h" #include "dest.h" #include "shipment.h" // Function Prototypes int inputInteger(); double inputDouble(); void getWord(char *, int); void main() { char Temp[30]; char temp; shipment S(); cout << "Please enter shipping info for a package,\n or STOP to quit."; cout << "\n\nShip To Name: "; getWord(Temp[], 30); while (!(strncmp(Temp, "STOP", 4) == 0)) { S.setName(Temp[]); cout << "Address: "; getWord(Temp[], 20); S.setStreet(Temp[]); cout << "City: "; getWord(Temp[], 20); S.setCity(Temp[]); cout << "State: "; getWord(Temp[], 2); S.setState(Temp[]); cout << "Zip: "; getWord(Temp[], 10); S.setZip(Temp[]); cout << "Package Info:\n-------------\nLength: "; S.setLength(inputInteger()); cout << "Width: "; S.setGirth(inputInteger()); cout << "Weight: "; S.setWeight(inputDouble()); if(S.goodShip() == 1) { cout << "Shipping Method: "; cin.get(temp); S.setMethod(temp); cout << "\n\nYour Shipping Label:"; S.printLabel(); } else cout << "Sorry, that package is too large to ship."; cout << "\n\nShip To Name: "; getWord(Temp[], 30); } cout << "\n\nProgram Ends." << endl; } void getWord(char *bar, int len) { cin.getline(*bar, len, '\n'); for (int i = 0; i < 30; i++) bar[i] = toupper(bar[i]); } int inputInteger() { int num; char strnum[10], *rptr; cin.getline(strnum, 9); num = strtol(strnum, &rptr, 0); while ((*rptr) != '\0') { cout << "\n\tError. Please Reenter: "; cin.getline(strnum, 9); num = strtol(strnum, &rptr, 0); } return(num); } double inputDouble() { double num; char strnum[20], *rptr; cin.getline(strnum, 19); num = strtod(strnum, &rptr); while ((*rptr) != '\0') { cout << "\n\tError. Please Reenter: "; cin.getline(strnum, 9); num = strtod(strnum, &rptr); } return(num); }