create a software using object oriented programming for a dentist that maintains data for his patients along with their history.
application should be capable of storing, modifying and displaying data. provide a menu driven solution.
plz frndz i need this code urgntly
i tried it by my self but i have some problems i dont know how to add parameterized constructor and em olredy having error in header file
here is the code
class patient
{
private:
int p_id;
char name(20);
int age;
char adress(50);
int phone_no;
char history(100);
char last_appointment(20);
char next_appointment(20);
public:
patient();
};
#include<stdio,h>
#include<conio.h>
#include<string.h>
#include<windows.h>
using namespace std
#include"patient.h"
void patient.patient()
{
p_id=0;
}
void patient::get_data()
int n;
cout<<"enter the number of the patients"<<endl;
cin>>n;
patient p[10];
for(int i=0; i<n; i++)
{
cout<<"\nEnter Patient ID=\n";
cin>>p_id;
cout<<"Enter Name of Patient=";
cin>>p[i].name;
cout<<"\nEnter Age of Patient=\n";
cin>>p[i].age;
cout<<"\nEnter Address of Patient";
cin>>[pi]adress;
cout<<"\nEnter Contect No.=\n";
cin>>p[i].phone_no;
cout<<"Enter History of Patient=";
cin>>p[i].history;
cout<<"Enter Last visit of Patient=";
cin>>p[i].last_appointment;
cout<<"Enter Next visit date of Patient=";
cin>>p[i].next_appointment;
}
void patient::display_data()
{
cout <<"\n\n;
cout << "\t\t====== PATIENT INFORMATION SYSTEM ======";
cout << "\n\n";
cout<<"\nPatient Name="<<p[i].name<<endl;
cout<<"\nPatient ID="<<p[i].p_id;
cout<<"\nPatient Address="<<p[i].adress;
cout<<"\nContect Number="<<p[i].phone_no;
cout<<"\nPatient Medical History="<<p[i].history;
cout<<"\nLast visit of Patient="<<p[i].last_appointment;
cout<<"\nNext Appointment="<<p[i].next_appointment;
cout<<"\t\t=========End================";
}
void patient::modify_data()
{
cout<<"\nEnter Patient ID=\n";
cin>>p_id;
cout<<"Enter Name of Patient=";
cin>>name;
cout<<"\nEnter Age of Patient=\n";
cin>>age;
cout<<"\nEnter Address of Patient";
cin>>adress;
cout<<"\nEnter Contect No.=\n";
cin>>phone_no;
cout<<"Enter History of Patient=";
cin>>history;
cout<<"Enter Last visit of Patient=";
cin>>last_appointment;
cout<<"Enter Next visit date of Patient=";
cin>>next_appointment;
}
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<windows.h>
using namespace std
#include"patient.h"
void main()
{
patient p1, p2;
do
{
system("cls");
cout<<"\n\n\n\tMAIN MENU";
cout<<"\n\n\t01. Get_Data";
cout<<"\n\n\t02. Display_Data";
cout<<"\n\n\t03. Modify Data";
cout<<"\n\n\tPlease Select Your Option (1-3) ";
cin>>ch;
switch(ch)
{
case '1': get_data();
break;
case '2': display_data();
break;
case '3': modify_data();
case '4':
break;
Here's something roughly similar that I made a little over a year ago, hope it helps. It's a phonebook and there is plenty of crap and/or useless code in here, but it may give you some ideas.
#ifndef PHONEBOOK_H
#define PHONEBOOK_H
#include <list>
//#include <string> // included in Person.h
#include "Person.h"
class PhoneBook
{
public:
void AddInfo(Person&);
void RemoveInfo(int);
void PrintInfo(int);
int FindInfo(std::string);
void SwapInfo(int, int);
int GetSize();
std::_List_iterator<Person> GetFirstPerson(); //I could either return iterator or dereferenced iterator, but I'll just use -> to access the objects function
std::_List_iterator<Person> GetLastPerson();
std::_List_iterator<Person> GetPerson(int);
private:
std::list<Person> info;
std::list<Person>::iterator itr1, itr2; //2 iterators are needed for swaping, or at least it makes it easier
};
#endif // PHONEBOOK_H
#include "PhoneBook.h"
//#include <iostream> // included in Person.h
void PhoneBook::AddInfo(Person &person)
{
info.push_back(person);
}
void PhoneBook::RemoveInfo(int index)
{
if ((unsignedint)index > info.size() || index < 0) //unsigning the int removes the warning, not sure if it would be better to leave the warning as it was
{
std::cout << "[ERROR] That request is out of range" << std::endl;
return;
}
itr1 = info.begin();
std::advance(itr1, index);
info.erase(itr1);
}
void PhoneBook::PrintInfo(int index)
{
std::cout << std::endl;
if ((unsignedint)index > info.size() && index >= 0)
{
std::cout << "[ERROR] That request is out of range." << std::endl;
return;
}
itr1 = info.begin();
if (index < 0)
{
std::cout << "Printing all known contacts." << std::endl;
for(unsignedint c = 0; c < info.size(); c++) // the index number, something that Person.cpp can't provide
{
std::cout << "[" << c << "] ";
itr1->PrintInfo(); //the objects PrintInfo() function
itr1++;
}
std::cout << "No more known contacts." << std::endl;
}
else
{
std::advance(itr1, index);
std::cout << "[" << index << "] ";
itr1->PrintInfo();
}
std::cout << std::endl;
}
int PhoneBook::FindInfo(std::string search)
{
itr1 = info.begin();
for(unsignedint index = 0; index < info.size(); index++)
{
if (itr1->GetFirstName() == search || itr1->GetLastName() == search || itr1->GetNumber() == search) //quite a specific search, not partial
{
std::cout << "Person Found: [" << index << "] ";
itr1->PrintInfo();
return index; //useful if I want to call this function inside a function which needs an index
}
else itr1++;
}
std::cout << "No Matches Found." << std::endl;
return -1;
}
void PhoneBook::SwapInfo(int index1, int index2)
{
if ((unsignedint)index1 > info.size() || (unsignedint)index2 > info.size() || index1 < 0 || index2 < 0)
{
std::cout << "[ERROR] That request is out of range." << std::endl;
return;
}
itr1 = info.begin();
itr2 = info.begin();
std::advance(itr1, index1); // itr1 = person one
std::advance(itr2, index2); // itr2 = person two
info.insert(itr2, *itr1); // copy person one to the slot below person two
info.insert(itr1, *itr2);
this->RemoveInfo(index2 + 2); // 2 elements inserted, so aim 2 elements higher
this->RemoveInfo(index1 + 1); // remove original person 2 which is currently above person 1
std::cout << "[" << index1 << "] " << itr1->GetFirstName() << " " << itr1->GetLastName() << " has been swaped with [" << index2 << "] " << itr2->GetFirstName() << " " << itr2->GetLastName() << std::endl;
}
int PhoneBook::GetSize()
{
return info.size();
}
std::_List_iterator<Person> PhoneBook::GetFirstPerson()
{
return info.begin();
}
std::_List_iterator<Person> PhoneBook::GetLastPerson()
{
itr1 = info.end();
itr1--;
return itr1;
}
std::_List_iterator<Person> PhoneBook::GetPerson(int index)
{
itr1 = info.begin();
advance (itr1, index);
return itr1;
}