Here's my driver code
Expand|Select|Wrap|Line Numbers
- #include"Animal.h"
- #include"Client.h"
- #include"Removal.h"
- #include"Date.h"
- #include"Animal.h"
- #include"TelNo.h"
- #include"Time.h"
- #include"Address.h"
- #include"Intervention.h"
- #include <iomanip>
- #include<iostream>
- #include<istream>
- #include<string>
- #include<stdio.h>
- #include<stdlib.h>
- #include <fstream>
- #include<ostream>
- using namespace std;
- void Mainmenu();
- void Showclinic();
- void addVisit(string, Intervention);
- void ViewAll();
- int main()
- {
- Mainmenu();
- return 0;
- }
- void Mainmenu()
- {
- int option;
- cout << "1: Clinic Visit\t\t";
- cout << "2: Removal\t\t";
- cout << "3: Exit Visit\t\t\n";
- cout << "Select an option\n\n\n";
- cin >> option;
- system("cls");
- switch (option)
- {
- case 1:
- Showclinic();
- break;
- case 2: //RemAnimal();
- break;
- case 3:
- exit(0);
- break;
- default:
- cout << "unknown option";
- }
- }
- void Showclinic()
- {
- int x;
- Intervention inte;
- cout << "1: ADD\n\n";
- cout << "2: UPDATE\n\n";
- cout << "3: VIEW\n\n";
- cout << "4: VIEW ALL\n\n";
- cout << "5: DELETE\n\n";
- cout << "6: Exit\n\n";
- cout << "Enter Choice\n";
- cin >> x;
- switch (x)
- {
- case 1:
- system("cls");
- cout << "CURRENTLY ADDING DATA\n";
- addVisit("JSPCA.txt", inte);
- break;
- case 2:
- cout << "UPDATE";
- system("cls");
- break;
- case 3:
- cout << "VIEW";
- system("cls");
- break;
- case 4:system("cls");
- cout << "VIEW ALL RECORDS ON FILE\n";
- ViewAll();
- //inte.display();
- system("pause");
- break;
- case 5:system("cls");
- cout << "DELETE";
- system("cls");
- break;
- case 6:
- cout << "EXIT";
- exit(0);
- break;
- default:
- cout << "value of x unknown";
- }
- }
- //***********************************************************************
- void addVisit(string name, Intervention inte)
- {
- int hour, min, day, month, yr, snum, age;
- string fname, lname, interNo, problem, clinic, area, ex, li, type, breed, gender, sname, town, pay;
- cout << "Enter new intervention number\n";
- cin >> interNo;
- // user enters information, which is copied into file
- cout << "Enter name of clinic(Winchester or Caymanas)\n ";
- cin >> clinic;
- cout << "Enter lastname, firstname\n ";
- cin >> lname;
- cin >> fname;
- cout << "Please Address(Street#, Street Name, Town)\n";
- cin >> snum >> sname >> town;
- cout << "Enter Contact#:(area exchange line)\n";
- cin >> area >> ex >> li;
- cout << "Enter Animal Type, Breed,Gender and Age\n";
- cin >> type >> breed >> gender >> age;
- cout << "Please specify problem\n";
- cin >> problem;
- cout <<( "Please enter letter for payment type:\n");
- cout << ("Full=F\n");
- cout << ("Contribution=C\n");
- cout << ("Can't Pay=CP\n");
- cin >> pay;
- cout << "Enter date in format month dd mm yyyy\n";
- cin >> day >> month >> yr;
- cout << "Enter the time(hour minute\n)";
- cin >> hour >> min;
- // set record InterventionNo, Client,animal, date and time values
- //inte.setInterventionNo(input);
- inte.setClient(Client(fname, lname, pay,interNo,clinic));
- inte.setAddress(Address(snum, sname, town));
- inte.setTelNo(TelNo(area, ex, li));
- inte.setAnimal(Animal(type, breed, gender, age, problem));
- inte.setDate(Date(day, month, yr));
- inte.setTime(Time(hour, min));
- ofstream clientfile(name, ios::app);
- if (clientfile)
- {
- clientfile << inte.getClient().getInterventionNo() << "";
- clientfile << inte.getClient().getClinic() << "";
- clientfile << inte.getClient().getFname() << "";
- clientfile << inte.getClient().getLname() << "";
- clientfile << inte.getClient().getPayment() << "";
- clientfile << inte.getAddress().getStreetNo() << "";
- clientfile << inte.getAddress().getStreetName() << "";
- clientfile << inte.getAddress().getTown() << "";
- clientfile << inte.getTelNo().getAreaCode() << "";
- clientfile << inte.getTelNo().getExchange() << "";
- clientfile << inte.getTelNo().getLine() << "";
- clientfile << inte.getAnimal().getBreed() << "";
- clientfile << inte.getAnimal().getType() << "";
- clientfile << inte.getAnimal().getGender() << "";
- clientfile << inte.getAnimal().getAge() << "";
- clientfile << inte.getAnimal().getProblem() << "";
- clientfile << inte.getDate().getDay() << "";
- clientfile << inte.getDate().getMonth() << "";
- clientfile << inte.getDate().getYear() << "";
- clientfile << inte.getTime().getHour() << "";
- clientfile << inte.getTime().getMin() << "";
- clientfile << endl;
- clientfile.close();
- }//end if
- else{
- cerr << "Intervention #" << interNo << " already contains information. " << endl;
- }
- }
- //**********************************************************************
- Intervention ViewAll(string name, Intervention inte)
- {
- ifstream clientfile(name, ios::in);
- if (clientfile)
- {
- int hour, min, day, month, yr, snum, age;
- string fname, lname, interNo, problem, clinic, area, ex, li, type, breed, gender, sname, town, pay;
- while (clientfile && !clientfile.eof())
- { //needed to loop through each record in the file
- clientfile >> interNo;
- clientfile >> clinic;
- clientfile >> lname;
- clientfile >> fname;
- clientfile >> pay;
- clientfile >> snum;
- clientfile >> sname;
- clientfile>> town;
- clientfile >> area;
- clientfile >> ex;
- clientfile >> li;
- clientfile >> type;
- clientfile >> breed;
- clientfile >> gender;
- clientfile >> problem;
- clientfile >> age;
- clientfile >> day;
- clientfile >> month;
- clientfile >> yr;
- clientfile >> hour;
- clientfile >> min;
- if (fname == inte.getClient().getFname())
- {
- break;
- }
- }
- //after record is found, create record
- inte.getClient();
- inte.display();
- system("pause");
- }
- return inte;
- }