SlideShare a Scribd company logo
1 of 56
Download to read offline
#include
#include"Data.h"
#include"Person.h"
#include"Report.h"
#include
#include
#include "Menu.h"
using namespace std;
/*
Programmers: Javier A. Molina, Eduardo Bonnet
Students #:79249
*/
int main()
{
int cnt;
int idx;
string fileName;
Report * telefonia;
Menu menu("Reports");
bool fileNameExists(string fileName);
Report * addReport(Report * reports, int & totalReports);
Report * delReport(Report * reports, int & totalReports, int idx);
int displayReports(Report * reports, int totalReports);
menu.addItem("New report");
menu.addItem("Delete a report");
menu.addItem("Display a report");
cnt = 0;
telefonia = NULL;
do {
cout << menu;
cin >> menu;
//cls();
switch (menu.getOption()) {
case 1:
cout << "Enter report name (TE?????): ";
cin >> fileName;
if (fileNameExists(fileName + ".tel")) {
telefonia = addReport(telefonia, cnt);
idx = cnt - 1;
telefonia[idx].setFileName(fileName);
// telefonia[idx].loadReport();
}
else {
cls();
cerr << "Error: Report name '" << fileName << "' does not exists!   ";
//pause();
}
break;
case 2:
if (telefonia != NULL) {
do {
cls();
cout << "Delete a Report:  ";
idx = displayReports(telefonia, cnt);
if (between(idx, 0, cnt - 1)) {
cls();
telefonia = delReport(telefonia, cnt, idx);
idx = 0;
// pause();
}
} while (idx != cnt);
}
else {
cerr << "No reports available for deleting!   ";
//pause();
}
break;
case 3:
char ans;
if (telefonia != NULL) {
do {
// cls();
cout << "Display/Filed a Report:  ";
idx = displayReports(telefonia, cnt);
if (between(idx, 0, cnt - 1)) {
// cls();
cout << "Would you like the report to be display otherwise save into a file? ";
cin >> ans;
cls();
cin.ignore();
if (upper(ans) == 'Y') {
cout << telefonia[idx] << endl;
}
else {
//telefonia[idx].saveReport();
cout << "Report '" << telefonia[idx].getFileName() << "' saved as '" <<
telefonia[idx].getFileName() << ".rep'.  ";
}
//pause();
}
} while (idx != cnt);
}
else {
cerr << "No reports available for displaying!   ";
// pause();
}
break;
case 4:
cout << "Thanks for using Telefonia Reports System!!!   ";
break;
}
} while (menu.getLast() != menu.getOption());
delete[] telefonia;
return 0;
}
//Funcion que verifica si existe un archivo en disco
bool fileNameExists(string fileName) {
ifstream fin(fileName.c_str());
bool exists = !(fin.fail());
if (exists) fin.close();
return(exists);
}
//Anade dinamicamente objetos tipo Report al arreglo reports
Report * addReport(Report * reports, int & totalReports) {
if (totalReports == 0) {
reports = new Report[1];
}
else {
Report * tmp = new Report[totalReports];
for (int i = 0; i < totalReports; ++i) {
tmp[i] = reports[i];
}
delete[] reports;
reports = new Report[totalReports + 1];
for (int i = 0; i < totalReports; ++i) {
reports[i] = tmp[i];
}
delete[] tmp;
}
totalReports++;
return(reports);
}
//Borra objetos del arreglo reports segun el idx enviado
Report * delReport(Report * reports, int & totalReports, int idx) {
Report * tmp = new Report[totalReports - 1];
string fileName = reports[idx].getFileName();
for (int i = 0, j = 0; i < totalReports; ++i) {
if (i == idx) continue;
tmp[j] = reports[i];
j++;
}
delete[] reports;
totalReports--;
reports = new Report[totalReports];
for (int i = 0; i < totalReports; ++i) {
reports[i] = tmp[i];
}
delete[] tmp;
cout << "Report '" << fileName << "' has been deleted! " << endl;
if (totalReports == 0) reports = NULL;
return(reports);
}
//Muestra en pantalla la lista de informes que se encuantran en memoria
int displayReports(Report * reports, int totalReports) {
int choice;
int i;
for (i = 0; i < totalReports; ++i) {
cout << "t" << (i + 1) << ".) " << reports[i].getFileName() << endl;
}
cout << "t" << (i + 1) << ".) Return ";
cout << " tChoice: ";
cin >> choice;
return (choice - 1);
}
Data.h
#include
#include
#include
#ifndef DATA_H
#define DATA_H
#include "Person.h"
using namespace std;
#pragma once
//Trata de establecer coneccion entre la clase data y person, utilizando informacion de la clase
person busca informacion de las llamadas hechas por el cliente
//Person(client) con esto saca la informacion de los datos escritos en la clase
class Data
{
private:
Person client;//atributo de la clase person
string callDate;//atributos esenciales de la clase Data
bool longDistance;
string timeCallBegin;
string timeCallEnd;
string callNoFrom;
string callNoTo;
public:
Data();//default
Data(Person client, string callDate, bool longDistance, string timeCallBegin, string
timeCallEnd, string callNoFrom, string callNoTo);//parameter constructor
Data(const Data & unData);//copy constructor
~Data();//destructor
void setClient(const Person & client);//setters
void setCallDate(string callDate);
void setLongDistance(bool longDistance);
void setTimeCallBegin(string timeCallBegin);
void setTimeCallEnd(string timeCallEnd);
void setCallNoFrom(string callNoFrom);
void setCallNoTo(string callNoTo);
Person getClient()const;//getters
string getCallDate()const;
bool getLongDistance()const;
string getTimeCallBegin()const;
string getTimeCallEnd()const;
string getCallNoFrom()const;
string getCallNoTo()const;
Data & operator = (const Data & unData);//operador de asignar
bool operator ==(const Data & unData)const;//operador de igualdad
friend ostream & operator <<(ostream & output, const Data & unData);//friend operador,
imprime valores
friend istream & operator >>(istream & input, Data & unData);//friend operator, manipula los
valores de los atributos
};
#endif // DATA_H
Data.cpp
#include "Data.h"
using namespace std;
Data::Data()//default
{
setClient(Person(" "," "," "," "));
setCallDate(" ");//valores asignados por default
setLongDistance(false);
setTimeCallBegin(" ");
setTimeCallEnd(" ");
setCallNoFrom(" ");
setCallNoTo(" ");
}
Data::Data (Person client, string callDate, bool longDistance, string timeCallBegin, string
timeCallEnd, string callNoFrom, string callNoTo)//parameter constructor
{
setClient(client);
setCallDate(callDate);
setLongDistance(longDistance);
setTimeCallBegin(timeCallBegin);
setTimeCallEnd(timeCallEnd);
setCallNoFrom(callNoFrom);
setCallNoTo(callNoTo);
}
Data::Data(const Data & unData)//copy constructor
{
this->client = unData.client;
this->callDate = unData.callDate;
this->longDistance = unData.longDistance;
this->timeCallBegin = unData.timeCallBegin;
this->timeCallEnd = unData.timeCallEnd;
this->callNoFrom = unData.callNoFrom;
this->callNoTo = unData.callNoTo;
}
Data::~Data()//destructor
{
}
void Data::setClient(const Person & client)//setters
{
this->client = client;
}
void Data::setCallDate(string callDate)
{
this->callDate = callDate;
}
void Data::setLongDistance(bool longDistance)
{
if (longDistance == 1)//verificacion del valor para clasificar en true or false
{
longDistance = true;
this->longDistance = longDistance;
}
else
{
longDistance = false;
this->longDistance = longDistance;
}
}
void Data::setTimeCallBegin(string timeCallBegin)
{
this->timeCallBegin = timeCallBegin;
}
void Data::setTimeCallEnd(string timeCallEnd)
{
this->timeCallEnd = timeCallEnd;
}
void Data::setCallNoFrom(string callNoFrom)
{
this->callNoFrom = callNoFrom;
}
void Data::setCallNoTo(string callNoTo)
{
this->callNoTo = callNoTo;
}
Person Data::getClient()const//getters
{
return (this->client);
}
string Data::getCallDate()const
{
return (this->callDate);
}
bool Data::getLongDistance()const
{
return(this->longDistance);
}
string Data::getTimeCallBegin()const
{
return (this->timeCallBegin);
}
string Data::getTimeCallEnd()const
{
return (this->timeCallEnd);
}
string Data::getCallNoFrom()const
{
return (this->callNoFrom);
}
string Data::getCallNoTo()const
{
return(this->callNoTo);
}
Data & Data :: operator =(const Data & unData)//asigna los valores
{
this->client = unData.client;
this->callDate = unData.callDate;
this->longDistance = unData.longDistance;
this->timeCallBegin = unData.timeCallBegin;
this->timeCallEnd = unData.timeCallEnd;
this->callNoFrom = unData.callNoFrom;
this->callNoTo = unData.callNoTo;
return (*this);
}
bool Data :: operator ==(const Data & unData)const//verificacion de igualdad de todos los
valores
{
return (this->client == unData.client && this->callDate == unData.callDate && this-
>longDistance == unData.longDistance &&
this->timeCallBegin == unData.timeCallBegin && this->timeCallEnd ==
unData.timeCallEnd && this->callNoFrom == unData.callNoFrom &&
this->callNoTo == unData.callNoTo);
}
ostream & operator <<(ostream & output, const Data & unData)//imprime valores
{
Person person;
output << "Providing Client Information:" << endl;
output << person.getFirstName();
output << person.getLastName();
output << person.getMiddleName();
output << person.getMaidenName();
output << endl << "Call Date: " << unData.callDate << endl;
output << "longDistance Charge: " << unData.longDistance ? " Y " : " N ";//Yes or No
question
output << "Time Call Begin: " << unData.timeCallBegin;
output << "Time Call End: " << unData.timeCallEnd;
output << "Call # From: " << unData.callNoFrom;
output << "Call # to: " << unData.callNoTo;
return output;
}
istream & operator >>(istream & input, Data & unData)//pide valores
{
cout << "Client Information: " << endl;
input >> unData.client;
cout << "Call Date: " << endl;
input >> unData.callDate;
cout << " Long Distance: " << endl;
input >> unData.longDistance;
cout << " Time Call Begin: " << endl;
input >> unData.timeCallBegin;
cout << " Time Call End: " << endl;
input >> unData.timeCallEnd;
cout << " Call # From : " << endl;
input >> unData.callNoFrom;
cout << " Call # To: " << endl;
input >> unData.callNoTo;
return input;
}
Person.h
#pragma once
#include
#include
using namespace std;
class Person
{
private:
string firstName;
string lastName;
string middleName;
string maidenName;
public:
Person();
Person(string firstName, string lastName, string middleName, string maidenName);
Person(const Person & unPerson);//copy constructor
~Person();//destructor
void setFirstName(string firsName);//setters
void setLastName(string lastName);
void setMiddleName(string middleName);
void setMaidenName(string maidenName);
string getFirstName()const;//getters
string getLastName()const;
string getMiddleName()const;
string getMaidenName()const;
Person & operator = (const Person & unPerson);//operador de asignar valores
bool operator ==(const Person & unPerson)const;//operador de igualdad
friend ostream & operator <<(ostream & output, const Person & unPerson);//friend operador
que imprime
friend istream & operator >>(istream & input, Person & unPerson);//friend operador que pide
cambia valores
};
Person.cpp
#include "Person.h"
using namespace std;
Person::Person()//default cnstructor
{
firstName = (" ");//valores por default
lastName =(" ");
middleName =(" ");
maidenName = (" ");
}
Person::Person(string firstName, string lastName, string middleName, string
maidenName)//parameter
{
setFirstName(firstName);//nombrando las variables
setLastName(lastName);
setMiddleName(middleName);
setMaidenName(maidenName);
}
Person::Person(const Person & unPerson)//copy
{
firstName = unPerson.firstName;//asignando variables
lastName = unPerson.lastName;
middleName = unPerson.middleName;
maidenName = unPerson.maidenName;
}
Person::~Person()//destructor
{
}
void Person::setFirstName(string firstName)//setters
{
this->firstName = firstName;
}
void Person::setLastName(string lastName)
{
this->lastName = lastName;
}
void Person::setMiddleName(string middleName)
{
this->middleName = middleName;
}
void Person::setMaidenName(string maidenName)
{
this->maidenName = maidenName;
}
string Person::getFirstName()const//getters
{
return (this->firstName);
}
string Person::getLastName()const
{
return (this->lastName);
}
string Person::getMiddleName()const
{
return (this->middleName);
}
string Person::getMaidenName()const
{
return (this->maidenName);
}
Person & Person:: operator =(const Person & unPerson)//operador que asigna valores
{
this->firstName = unPerson.firstName;
this->lastName = unPerson.lastName;
this->middleName = unPerson.middleName;
this->maidenName = unPerson.maidenName;
return (*this);//retorna todos los valores guardados
}
bool Person:: operator == (const Person & unPerson)const//operador de igualdad y comparacion
de valores, verifica que sean iguales
{
return (this->firstName == unPerson.firstName && this->lastName == unPerson.lastName
&&
this->middleName == unPerson.middleName && this->maidenName ==
unPerson.maidenName);
}
ostream & operator <<(ostream & output, const Person & unPerson)//imprime valores
{
output << " First Name:  " << unPerson.firstName;
output << " LastName:  " << unPerson.lastName;
output << "MiddleName: " << unPerson.middleName;
output << " Maiden Name: " << unPerson.maidenName;
return output;
}
istream & operator >>(istream & input, Person & unPerson)//cambia o pide valores
{
cout << " Please Enter First Name t Middle Name t Last Name t Maiden Name " <<
endl;
input >> unPerson.firstName;
input >> unPerson.middleName;
input >> unPerson.lastName;
input >> unPerson.maidenName;
return input;
}
Menu.h
#pragma once
#include
#include
#include "MyLib.h"
using namespace::std;
#ifndef MENU_H
#define MENU_H
enum Choice { numeric, alpha };
enum Lang { eng, spa };
class Menu {
private:
string * items;
string title;
int totalItems;
Lang lang;
Choice choice;
int option;
flag validate;
flag subMenu;
public:
Menu()
{
init();
}
Menu(const char * title)
{
init();
this->title = title;
}
Menu(const Menu & aMenu)
{
init();
this->title = aMenu.title;
if (!aMenu.isEmpty()) {
for (int i = 0; i < aMenu.totalItems; ++i) {
addItem(aMenu.items[i]);
}
this->choice = aMenu.choice;
this->validate = aMenu.validate;
this->subMenu = aMenu.subMenu;
this->title = aMenu.title;
}
}
void init() {
this->items = NULL;
this->totalItems = 0;
this->lang = eng;
this->choice = numeric;
this->validate = false;
this->subMenu = false;
this->title = "Menu";
}
~Menu()
{
delete[] this->items;
}
bool isEmpty() const
{
return this->totalItems == 0;
}
void addItem(string item)
{
int idx = this->totalItems;
string * tmp;
int i;
if (isEmpty()) {
this->items = new string[1];
}
else {
tmp = new string[this->totalItems];
for (i = 0; i < this->totalItems; i++) {
tmp[i] = this->items[i];
}
delete[] this->items;
this->items = new string[this->totalItems + 1];
for (i = 0; i < this->totalItems; i++) {
this->items[i] = tmp[i];
}
delete[] tmp;
}
this->items[idx] = item;
this->totalItems++;
}
bool check()
{
if (this->choice == alpha) {
this->validate = between(char(option), 'A', char('A' + this->totalItems));
}
else {
this->validate = between(option, 1, this->totalItems + 1);
}
return this->validate;
}
void setChoice(Choice choice)
{
this->choice = choice;
}
void setOption(int option)
{
this->option = upper(option); check();
}
void setLang(Lang lang)
{
this->lang = lang;
}
void setTitle(string title)
{
this->title = title;
}
void setSubMenu(flag subMenu)
{
subMenu = subMenu;
}
Lang getLanguage() const
{
return this->lang;
}
int getOption() const
{
return this->option;
}
int getLast() const
{
if (this->choice == alpha) {
return char('A' + this->totalItems);
}
else {
return this->totalItems + 1;
}
}
friend ostream & operator <<(ostream & os, Menu & unMenu)
{
int i;
char ch = 'a';
cls();
os << unMenu.title << endl << endl;
for (i = 0; i < unMenu.totalItems; i++) {
os << "t";
if (unMenu.choice == alpha) os << char(ch + i); else os << i + 1;
os << ".) " << unMenu.items[i] << endl;
}
os << "t";
if (unMenu.choice == alpha) os << char(ch + i); else os << i + 1;
os << ".) ";
if (unMenu.lang == eng) {
if (unMenu.subMenu)
os << "Return";
else
os << "Exit";
os << "  Choose: ";
}
else {
if (unMenu.subMenu)
os << "Regresar";
else
os << "Salir";
os << " Opcion: ";
}
return os;
}
friend istream & operator >>(istream & in, Menu & unMenu)
{
do {
char opt;
in >> opt;
unMenu.setOption((unMenu.choice == alpha ? opt : opt - '0'));
if (!unMenu.check()) {
cerr << " Error: Wrong choice!!!  ";
pause();
cout << unMenu;
}
} while (!unMenu.check());
return in;
}
};
#endif // MENU_H
mylib.h
#pragma once
#include
#include
using namespace::std;
#ifndef MYLIB_H
#define MYLIB_H
typedef bool flag;
#ifdef WINDOWS
#define cls() system("cls")
#define pause() system("pause")
#elif windows
#define cls() system("cls")
#define pause() system("pause")
#elif LINUX
#define cls() system("clear")
#define pause() system("sleep 3")
#elif linux
#define cls() system("clear")
#define pause() system("sleep 3")
#else
#define cls() { cerr << "CLS: Unknown OS!!! "; }
#define pause() { cerr << "PAUSE: Unknown OS!!! "; }
#endif
#define between(x, y, z) ((x >= y && x <= z)? true : false)
#define upper(x) (between(x, 'A', 'Z')? x : (between(x, 'a', 'z')? x - 'a' + 'A' : x))
#define lower(x) (between(x, 'a', 'z')? x : x - 'A' + 'a')
#endif // MYLIB_H
DataParser.h
#include "DataParser.h"
#include
#include"Person.h"
#include"Report.h"
DataParser::DataParser()
{
record;
}
DataParser::DataParser(string line)
{
parseLine(line);
}
DataParser::DataParser(const DataParser & unDataParser)
{
this->record = unDataParser.record;
this->fecha = unDataParser.fecha;
}
DataParser::~DataParser()
{
}
Data DataParser::parseLine(string line)
{
Person client;//atributos de clase Person y Data
string callDate;
bool longDistance;
string timeCallBegin;
string timeCallEnd;
string callNoFrom;
string callNoTo;
string firstName;
string lastName;
string middleName;
string maidenName;
//substr demostrara en que linea
firstName = line.substr(0, 25);
middleName = line.substr(25, 25);
lastName = line.substr(50, 50);
maidenName = line.substr(100, 50);
callDate = line.substr(150, 8);
if (line.substr(158, 1) == "Y")//yes or no
longDistance = true;
else
longDistance = false;
timeCallBegin = line.substr(159, 6);
timeCallEnd = line.substr(165, 6);
callNoFrom = line.substr(171, 10);
callNoTo = line.substr(181, 10);
record.setClient(Person(firstName, middleName, lastName, maidenName));
record.setCallDate(callDate);
record.setLongDistance(longDistance);
record.setTimeCallBegin(timeCallBegin);
record.setTimeCallEnd(timeCallEnd);
record.setCallNoFrom(callNoFrom);
record.setCallNoTo(callNoTo);
return record;
}
void DataParser::setRecord(string line)
{
parseLine(line);
}
Data DataParser::getRecord() const
{
return (this->record);
}
string DataParser::date(string date)
{
string fecha;
fecha = date.substr(191, 2) + "/" + date.substr(193, 2) + "/" + date.substr(195, 4);
return fecha;
}
void DataParser::setFecha(int fecha)
{
this->fecha = fecha;
}
int DataParser::getFecha()const
{
return(this->fecha);
}
DataParser.h
#pragma once
#include
#include
#include "Data.h"
using namespace std;
class DataParser
{
private:
Data record;
int fecha;
public:
DataParser();
DataParser(string line);
DataParser(const DataParser & unDataPaser);
~DataParser();
void setRecord(string line);
void setFecha(int fecha);
int getFecha()const;
Data getRecord()const;
Data parseLine(string line);
string date(string date);
// friend ostream & operator <<(ostream & os, const DataParser & unDataParser);
// friend istream & operator >> (istream & is, DataParser & unDataParser);
};
Report.cpp
#include "Report.h"
Report::Report()
{
records = NULL;
totalRecords = 0;
totalMinutes = 0.0;
totalAmmount = 0.0;
fileName=(" ");
}
Report::Report(Data records, int totalRecords, float totalMinutes, float totalAmmount, string
fileName)
{
setTotalRecords(totalRecords);
setTotalMinutes(totalMinutes);
setTotalAmmount(totalAmmount);
setFileName(fileName);
}
void Report::addRecord(const Data & unData)
{
Data *records;
records = new Data[this->totalRecords + 1];
for (int i = 0;i < this->totalRecords;i++)
{
records[this->totalRecords] = unData;
delete[](this->records);
this->records = records;
++(this->records);
}
}
Report::Report(const Report & unReport)
{
this->records = NULL;
totalRecords = unReport.totalRecords;
totalMinutes = unReport.totalMinutes;
totalAmmount = unReport.totalAmmount;
fileName = unReport.fileName;
(*this) = unReport;
}
Report::~Report()
{
delete[](this->records);
}
void Report::setTotalRecords(int totalRecords)
{
this->totalRecords = totalRecords;
}
void Report::setTotalAmmount(float totalAmmount)
{
this->totalAmmount = totalAmmount;
}
void Report::setTotalMinutes(float totalMinutes)
{
this->totalMinutes = totalMinutes;
}
void Report::setFileName(string fileName)
{
this->fileName = fileName;
}
const Data & Report::operator[](int indice)const
{
return((this->records)[indice]);
}
Data Report::getRecords()const
{
for (int i = 0;i < totalRecords;i++)
{
return (records[i]);
}
}
int Report::getTotalRecords()const
{
return this->totalRecords;
}
float Report::getTotalAmmount()const
{
return this->totalAmmount;
}
float Report::getTotalMinutes()const
{
return this->totalMinutes;
}
string Report::getFileName()const
{
return this->fileName;
}
Report & Report::operator =(const Report & unReport)
{
delete[](this->records);
if (unReport.totalRecords > 0)
{
this->records = new Data[unReport.totalRecords];
for (int i = 0;i < unReport.totalRecords;i++)
{
(this->records[i] = (unReport.records)[i]);
}
}
else
{
this->records = NULL;
}
this->totalAmmount = unReport.totalAmmount;
this->totalMinutes = unReport.totalMinutes;
this->fileName = unReport.fileName;
return (*this);
}
bool Report::operator ==(const Report & unReport)const
{
bool record = false;
for (int i = 0;i < unReport.totalRecords;i++)
{
if (records[i] == unReport.records[i])
{
record = true;
}
return record;
}
return (this->totalRecords == unReport.totalRecords && this->totalAmmount ==
unReport.totalAmmount &&
this->totalMinutes == unReport.totalMinutes && this->fileName == unReport.fileName);
}
ostream & operator <<(ostream & os, const Report & unReport)
{
for (int i = 0; i < unReport.totalRecords;i++)
{
os << "Record number is: " << unReport.records[i] << endl;
}
return os;
}
istream & operator >>(istream & is, Report & unReport)
{
cout << "Enter record:" << unReport.records << endl;;
cout << "Total Records are: ";
is >> unReport.totalRecords;
cout << "Total Ammount: ";
is >> unReport.totalAmmount;
cout << "Total Minutes:";
is >> unReport.totalMinutes;
cout << "File name is: ";
is >> unReport.fileName;
return is;
}
Report.h
#pragma once
#include"Data.h"
#include
#include
using namespace std;
class Report
{
private:
Data *records;
int totalRecords;
float totalMinutes;
float totalAmmount;
string fileName;
public:
Report();
Report(Data records,int totalRecords, float totalMinutes, float totalAmmount, string
fileName);
Report(const Report & unReport);
~Report();
void addRecord(const Data & unData);
void setTotalRecords(int totalRecords);
void setTotalMinutes(float totalMinutes);
void setTotalAmmount(float totalAmmount);
void setFileName(string fileName);
const Data & operator[](int indice)const;
Data getRecords()const;
int getTotalRecords()const;
float getTotalMinutes()const;
float getTotalAmmount()const;
string getFileName()const;
Report & operator = (const Report & unReport);
bool operator ==(const Report & unReport)const;
friend ostream & operator<<(ostream & os, const Report & unReport);
friend istream & operator>>(istream & is, Report & unReport);
};
Solution
#include
#include"Data.h"
#include"Person.h"
#include"Report.h"
#include
#include
#include "Menu.h"
using namespace std;
/*
Programmers: Javier A. Molina, Eduardo Bonnet
Students #:79249
*/
int main()
{
int cnt;
int idx;
string fileName;
Report * telefonia;
Menu menu("Reports");
bool fileNameExists(string fileName);
Report * addReport(Report * reports, int & totalReports);
Report * delReport(Report * reports, int & totalReports, int idx);
int displayReports(Report * reports, int totalReports);
menu.addItem("New report");
menu.addItem("Delete a report");
menu.addItem("Display a report");
cnt = 0;
telefonia = NULL;
do {
cout << menu;
cin >> menu;
//cls();
switch (menu.getOption()) {
case 1:
cout << "Enter report name (TE?????): ";
cin >> fileName;
if (fileNameExists(fileName + ".tel")) {
telefonia = addReport(telefonia, cnt);
idx = cnt - 1;
telefonia[idx].setFileName(fileName);
// telefonia[idx].loadReport();
}
else {
cls();
cerr << "Error: Report name '" << fileName << "' does not exists!   ";
//pause();
}
break;
case 2:
if (telefonia != NULL) {
do {
cls();
cout << "Delete a Report:  ";
idx = displayReports(telefonia, cnt);
if (between(idx, 0, cnt - 1)) {
cls();
telefonia = delReport(telefonia, cnt, idx);
idx = 0;
// pause();
}
} while (idx != cnt);
}
else {
cerr << "No reports available for deleting!   ";
//pause();
}
break;
case 3:
char ans;
if (telefonia != NULL) {
do {
// cls();
cout << "Display/Filed a Report:  ";
idx = displayReports(telefonia, cnt);
if (between(idx, 0, cnt - 1)) {
// cls();
cout << "Would you like the report to be display otherwise save into a file? ";
cin >> ans;
cls();
cin.ignore();
if (upper(ans) == 'Y') {
cout << telefonia[idx] << endl;
}
else {
//telefonia[idx].saveReport();
cout << "Report '" << telefonia[idx].getFileName() << "' saved as '" <<
telefonia[idx].getFileName() << ".rep'.  ";
}
//pause();
}
} while (idx != cnt);
}
else {
cerr << "No reports available for displaying!   ";
// pause();
}
break;
case 4:
cout << "Thanks for using Telefonia Reports System!!!   ";
break;
}
} while (menu.getLast() != menu.getOption());
delete[] telefonia;
return 0;
}
//Funcion que verifica si existe un archivo en disco
bool fileNameExists(string fileName) {
ifstream fin(fileName.c_str());
bool exists = !(fin.fail());
if (exists) fin.close();
return(exists);
}
//Anade dinamicamente objetos tipo Report al arreglo reports
Report * addReport(Report * reports, int & totalReports) {
if (totalReports == 0) {
reports = new Report[1];
}
else {
Report * tmp = new Report[totalReports];
for (int i = 0; i < totalReports; ++i) {
tmp[i] = reports[i];
}
delete[] reports;
reports = new Report[totalReports + 1];
for (int i = 0; i < totalReports; ++i) {
reports[i] = tmp[i];
}
delete[] tmp;
}
totalReports++;
return(reports);
}
//Borra objetos del arreglo reports segun el idx enviado
Report * delReport(Report * reports, int & totalReports, int idx) {
Report * tmp = new Report[totalReports - 1];
string fileName = reports[idx].getFileName();
for (int i = 0, j = 0; i < totalReports; ++i) {
if (i == idx) continue;
tmp[j] = reports[i];
j++;
}
delete[] reports;
totalReports--;
reports = new Report[totalReports];
for (int i = 0; i < totalReports; ++i) {
reports[i] = tmp[i];
}
delete[] tmp;
cout << "Report '" << fileName << "' has been deleted! " << endl;
if (totalReports == 0) reports = NULL;
return(reports);
}
//Muestra en pantalla la lista de informes que se encuantran en memoria
int displayReports(Report * reports, int totalReports) {
int choice;
int i;
for (i = 0; i < totalReports; ++i) {
cout << "t" << (i + 1) << ".) " << reports[i].getFileName() << endl;
}
cout << "t" << (i + 1) << ".) Return ";
cout << " tChoice: ";
cin >> choice;
return (choice - 1);
}
Data.h
#include
#include
#include
#ifndef DATA_H
#define DATA_H
#include "Person.h"
using namespace std;
#pragma once
//Trata de establecer coneccion entre la clase data y person, utilizando informacion de la clase
person busca informacion de las llamadas hechas por el cliente
//Person(client) con esto saca la informacion de los datos escritos en la clase
class Data
{
private:
Person client;//atributo de la clase person
string callDate;//atributos esenciales de la clase Data
bool longDistance;
string timeCallBegin;
string timeCallEnd;
string callNoFrom;
string callNoTo;
public:
Data();//default
Data(Person client, string callDate, bool longDistance, string timeCallBegin, string
timeCallEnd, string callNoFrom, string callNoTo);//parameter constructor
Data(const Data & unData);//copy constructor
~Data();//destructor
void setClient(const Person & client);//setters
void setCallDate(string callDate);
void setLongDistance(bool longDistance);
void setTimeCallBegin(string timeCallBegin);
void setTimeCallEnd(string timeCallEnd);
void setCallNoFrom(string callNoFrom);
void setCallNoTo(string callNoTo);
Person getClient()const;//getters
string getCallDate()const;
bool getLongDistance()const;
string getTimeCallBegin()const;
string getTimeCallEnd()const;
string getCallNoFrom()const;
string getCallNoTo()const;
Data & operator = (const Data & unData);//operador de asignar
bool operator ==(const Data & unData)const;//operador de igualdad
friend ostream & operator <<(ostream & output, const Data & unData);//friend operador,
imprime valores
friend istream & operator >>(istream & input, Data & unData);//friend operator, manipula los
valores de los atributos
};
#endif // DATA_H
Data.cpp
#include "Data.h"
using namespace std;
Data::Data()//default
{
setClient(Person(" "," "," "," "));
setCallDate(" ");//valores asignados por default
setLongDistance(false);
setTimeCallBegin(" ");
setTimeCallEnd(" ");
setCallNoFrom(" ");
setCallNoTo(" ");
}
Data::Data (Person client, string callDate, bool longDistance, string timeCallBegin, string
timeCallEnd, string callNoFrom, string callNoTo)//parameter constructor
{
setClient(client);
setCallDate(callDate);
setLongDistance(longDistance);
setTimeCallBegin(timeCallBegin);
setTimeCallEnd(timeCallEnd);
setCallNoFrom(callNoFrom);
setCallNoTo(callNoTo);
}
Data::Data(const Data & unData)//copy constructor
{
this->client = unData.client;
this->callDate = unData.callDate;
this->longDistance = unData.longDistance;
this->timeCallBegin = unData.timeCallBegin;
this->timeCallEnd = unData.timeCallEnd;
this->callNoFrom = unData.callNoFrom;
this->callNoTo = unData.callNoTo;
}
Data::~Data()//destructor
{
}
void Data::setClient(const Person & client)//setters
{
this->client = client;
}
void Data::setCallDate(string callDate)
{
this->callDate = callDate;
}
void Data::setLongDistance(bool longDistance)
{
if (longDistance == 1)//verificacion del valor para clasificar en true or false
{
longDistance = true;
this->longDistance = longDistance;
}
else
{
longDistance = false;
this->longDistance = longDistance;
}
}
void Data::setTimeCallBegin(string timeCallBegin)
{
this->timeCallBegin = timeCallBegin;
}
void Data::setTimeCallEnd(string timeCallEnd)
{
this->timeCallEnd = timeCallEnd;
}
void Data::setCallNoFrom(string callNoFrom)
{
this->callNoFrom = callNoFrom;
}
void Data::setCallNoTo(string callNoTo)
{
this->callNoTo = callNoTo;
}
Person Data::getClient()const//getters
{
return (this->client);
}
string Data::getCallDate()const
{
return (this->callDate);
}
bool Data::getLongDistance()const
{
return(this->longDistance);
}
string Data::getTimeCallBegin()const
{
return (this->timeCallBegin);
}
string Data::getTimeCallEnd()const
{
return (this->timeCallEnd);
}
string Data::getCallNoFrom()const
{
return (this->callNoFrom);
}
string Data::getCallNoTo()const
{
return(this->callNoTo);
}
Data & Data :: operator =(const Data & unData)//asigna los valores
{
this->client = unData.client;
this->callDate = unData.callDate;
this->longDistance = unData.longDistance;
this->timeCallBegin = unData.timeCallBegin;
this->timeCallEnd = unData.timeCallEnd;
this->callNoFrom = unData.callNoFrom;
this->callNoTo = unData.callNoTo;
return (*this);
}
bool Data :: operator ==(const Data & unData)const//verificacion de igualdad de todos los
valores
{
return (this->client == unData.client && this->callDate == unData.callDate && this-
>longDistance == unData.longDistance &&
this->timeCallBegin == unData.timeCallBegin && this->timeCallEnd ==
unData.timeCallEnd && this->callNoFrom == unData.callNoFrom &&
this->callNoTo == unData.callNoTo);
}
ostream & operator <<(ostream & output, const Data & unData)//imprime valores
{
Person person;
output << "Providing Client Information:" << endl;
output << person.getFirstName();
output << person.getLastName();
output << person.getMiddleName();
output << person.getMaidenName();
output << endl << "Call Date: " << unData.callDate << endl;
output << "longDistance Charge: " << unData.longDistance ? " Y " : " N ";//Yes or No
question
output << "Time Call Begin: " << unData.timeCallBegin;
output << "Time Call End: " << unData.timeCallEnd;
output << "Call # From: " << unData.callNoFrom;
output << "Call # to: " << unData.callNoTo;
return output;
}
istream & operator >>(istream & input, Data & unData)//pide valores
{
cout << "Client Information: " << endl;
input >> unData.client;
cout << "Call Date: " << endl;
input >> unData.callDate;
cout << " Long Distance: " << endl;
input >> unData.longDistance;
cout << " Time Call Begin: " << endl;
input >> unData.timeCallBegin;
cout << " Time Call End: " << endl;
input >> unData.timeCallEnd;
cout << " Call # From : " << endl;
input >> unData.callNoFrom;
cout << " Call # To: " << endl;
input >> unData.callNoTo;
return input;
}
Person.h
#pragma once
#include
#include
using namespace std;
class Person
{
private:
string firstName;
string lastName;
string middleName;
string maidenName;
public:
Person();
Person(string firstName, string lastName, string middleName, string maidenName);
Person(const Person & unPerson);//copy constructor
~Person();//destructor
void setFirstName(string firsName);//setters
void setLastName(string lastName);
void setMiddleName(string middleName);
void setMaidenName(string maidenName);
string getFirstName()const;//getters
string getLastName()const;
string getMiddleName()const;
string getMaidenName()const;
Person & operator = (const Person & unPerson);//operador de asignar valores
bool operator ==(const Person & unPerson)const;//operador de igualdad
friend ostream & operator <<(ostream & output, const Person & unPerson);//friend operador
que imprime
friend istream & operator >>(istream & input, Person & unPerson);//friend operador que pide
cambia valores
};
Person.cpp
#include "Person.h"
using namespace std;
Person::Person()//default cnstructor
{
firstName = (" ");//valores por default
lastName =(" ");
middleName =(" ");
maidenName = (" ");
}
Person::Person(string firstName, string lastName, string middleName, string
maidenName)//parameter
{
setFirstName(firstName);//nombrando las variables
setLastName(lastName);
setMiddleName(middleName);
setMaidenName(maidenName);
}
Person::Person(const Person & unPerson)//copy
{
firstName = unPerson.firstName;//asignando variables
lastName = unPerson.lastName;
middleName = unPerson.middleName;
maidenName = unPerson.maidenName;
}
Person::~Person()//destructor
{
}
void Person::setFirstName(string firstName)//setters
{
this->firstName = firstName;
}
void Person::setLastName(string lastName)
{
this->lastName = lastName;
}
void Person::setMiddleName(string middleName)
{
this->middleName = middleName;
}
void Person::setMaidenName(string maidenName)
{
this->maidenName = maidenName;
}
string Person::getFirstName()const//getters
{
return (this->firstName);
}
string Person::getLastName()const
{
return (this->lastName);
}
string Person::getMiddleName()const
{
return (this->middleName);
}
string Person::getMaidenName()const
{
return (this->maidenName);
}
Person & Person:: operator =(const Person & unPerson)//operador que asigna valores
{
this->firstName = unPerson.firstName;
this->lastName = unPerson.lastName;
this->middleName = unPerson.middleName;
this->maidenName = unPerson.maidenName;
return (*this);//retorna todos los valores guardados
}
bool Person:: operator == (const Person & unPerson)const//operador de igualdad y comparacion
de valores, verifica que sean iguales
{
return (this->firstName == unPerson.firstName && this->lastName == unPerson.lastName
&&
this->middleName == unPerson.middleName && this->maidenName ==
unPerson.maidenName);
}
ostream & operator <<(ostream & output, const Person & unPerson)//imprime valores
{
output << " First Name:  " << unPerson.firstName;
output << " LastName:  " << unPerson.lastName;
output << "MiddleName: " << unPerson.middleName;
output << " Maiden Name: " << unPerson.maidenName;
return output;
}
istream & operator >>(istream & input, Person & unPerson)//cambia o pide valores
{
cout << " Please Enter First Name t Middle Name t Last Name t Maiden Name " <<
endl;
input >> unPerson.firstName;
input >> unPerson.middleName;
input >> unPerson.lastName;
input >> unPerson.maidenName;
return input;
}
Menu.h
#pragma once
#include
#include
#include "MyLib.h"
using namespace::std;
#ifndef MENU_H
#define MENU_H
enum Choice { numeric, alpha };
enum Lang { eng, spa };
class Menu {
private:
string * items;
string title;
int totalItems;
Lang lang;
Choice choice;
int option;
flag validate;
flag subMenu;
public:
Menu()
{
init();
}
Menu(const char * title)
{
init();
this->title = title;
}
Menu(const Menu & aMenu)
{
init();
this->title = aMenu.title;
if (!aMenu.isEmpty()) {
for (int i = 0; i < aMenu.totalItems; ++i) {
addItem(aMenu.items[i]);
}
this->choice = aMenu.choice;
this->validate = aMenu.validate;
this->subMenu = aMenu.subMenu;
this->title = aMenu.title;
}
}
void init() {
this->items = NULL;
this->totalItems = 0;
this->lang = eng;
this->choice = numeric;
this->validate = false;
this->subMenu = false;
this->title = "Menu";
}
~Menu()
{
delete[] this->items;
}
bool isEmpty() const
{
return this->totalItems == 0;
}
void addItem(string item)
{
int idx = this->totalItems;
string * tmp;
int i;
if (isEmpty()) {
this->items = new string[1];
}
else {
tmp = new string[this->totalItems];
for (i = 0; i < this->totalItems; i++) {
tmp[i] = this->items[i];
}
delete[] this->items;
this->items = new string[this->totalItems + 1];
for (i = 0; i < this->totalItems; i++) {
this->items[i] = tmp[i];
}
delete[] tmp;
}
this->items[idx] = item;
this->totalItems++;
}
bool check()
{
if (this->choice == alpha) {
this->validate = between(char(option), 'A', char('A' + this->totalItems));
}
else {
this->validate = between(option, 1, this->totalItems + 1);
}
return this->validate;
}
void setChoice(Choice choice)
{
this->choice = choice;
}
void setOption(int option)
{
this->option = upper(option); check();
}
void setLang(Lang lang)
{
this->lang = lang;
}
void setTitle(string title)
{
this->title = title;
}
void setSubMenu(flag subMenu)
{
subMenu = subMenu;
}
Lang getLanguage() const
{
return this->lang;
}
int getOption() const
{
return this->option;
}
int getLast() const
{
if (this->choice == alpha) {
return char('A' + this->totalItems);
}
else {
return this->totalItems + 1;
}
}
friend ostream & operator <<(ostream & os, Menu & unMenu)
{
int i;
char ch = 'a';
cls();
os << unMenu.title << endl << endl;
for (i = 0; i < unMenu.totalItems; i++) {
os << "t";
if (unMenu.choice == alpha) os << char(ch + i); else os << i + 1;
os << ".) " << unMenu.items[i] << endl;
}
os << "t";
if (unMenu.choice == alpha) os << char(ch + i); else os << i + 1;
os << ".) ";
if (unMenu.lang == eng) {
if (unMenu.subMenu)
os << "Return";
else
os << "Exit";
os << "  Choose: ";
}
else {
if (unMenu.subMenu)
os << "Regresar";
else
os << "Salir";
os << " Opcion: ";
}
return os;
}
friend istream & operator >>(istream & in, Menu & unMenu)
{
do {
char opt;
in >> opt;
unMenu.setOption((unMenu.choice == alpha ? opt : opt - '0'));
if (!unMenu.check()) {
cerr << " Error: Wrong choice!!!  ";
pause();
cout << unMenu;
}
} while (!unMenu.check());
return in;
}
};
#endif // MENU_H
mylib.h
#pragma once
#include
#include
using namespace::std;
#ifndef MYLIB_H
#define MYLIB_H
typedef bool flag;
#ifdef WINDOWS
#define cls() system("cls")
#define pause() system("pause")
#elif windows
#define cls() system("cls")
#define pause() system("pause")
#elif LINUX
#define cls() system("clear")
#define pause() system("sleep 3")
#elif linux
#define cls() system("clear")
#define pause() system("sleep 3")
#else
#define cls() { cerr << "CLS: Unknown OS!!! "; }
#define pause() { cerr << "PAUSE: Unknown OS!!! "; }
#endif
#define between(x, y, z) ((x >= y && x <= z)? true : false)
#define upper(x) (between(x, 'A', 'Z')? x : (between(x, 'a', 'z')? x - 'a' + 'A' : x))
#define lower(x) (between(x, 'a', 'z')? x : x - 'A' + 'a')
#endif // MYLIB_H
DataParser.h
#include "DataParser.h"
#include
#include"Person.h"
#include"Report.h"
DataParser::DataParser()
{
record;
}
DataParser::DataParser(string line)
{
parseLine(line);
}
DataParser::DataParser(const DataParser & unDataParser)
{
this->record = unDataParser.record;
this->fecha = unDataParser.fecha;
}
DataParser::~DataParser()
{
}
Data DataParser::parseLine(string line)
{
Person client;//atributos de clase Person y Data
string callDate;
bool longDistance;
string timeCallBegin;
string timeCallEnd;
string callNoFrom;
string callNoTo;
string firstName;
string lastName;
string middleName;
string maidenName;
//substr demostrara en que linea
firstName = line.substr(0, 25);
middleName = line.substr(25, 25);
lastName = line.substr(50, 50);
maidenName = line.substr(100, 50);
callDate = line.substr(150, 8);
if (line.substr(158, 1) == "Y")//yes or no
longDistance = true;
else
longDistance = false;
timeCallBegin = line.substr(159, 6);
timeCallEnd = line.substr(165, 6);
callNoFrom = line.substr(171, 10);
callNoTo = line.substr(181, 10);
record.setClient(Person(firstName, middleName, lastName, maidenName));
record.setCallDate(callDate);
record.setLongDistance(longDistance);
record.setTimeCallBegin(timeCallBegin);
record.setTimeCallEnd(timeCallEnd);
record.setCallNoFrom(callNoFrom);
record.setCallNoTo(callNoTo);
return record;
}
void DataParser::setRecord(string line)
{
parseLine(line);
}
Data DataParser::getRecord() const
{
return (this->record);
}
string DataParser::date(string date)
{
string fecha;
fecha = date.substr(191, 2) + "/" + date.substr(193, 2) + "/" + date.substr(195, 4);
return fecha;
}
void DataParser::setFecha(int fecha)
{
this->fecha = fecha;
}
int DataParser::getFecha()const
{
return(this->fecha);
}
DataParser.h
#pragma once
#include
#include
#include "Data.h"
using namespace std;
class DataParser
{
private:
Data record;
int fecha;
public:
DataParser();
DataParser(string line);
DataParser(const DataParser & unDataPaser);
~DataParser();
void setRecord(string line);
void setFecha(int fecha);
int getFecha()const;
Data getRecord()const;
Data parseLine(string line);
string date(string date);
// friend ostream & operator <<(ostream & os, const DataParser & unDataParser);
// friend istream & operator >> (istream & is, DataParser & unDataParser);
};
Report.cpp
#include "Report.h"
Report::Report()
{
records = NULL;
totalRecords = 0;
totalMinutes = 0.0;
totalAmmount = 0.0;
fileName=(" ");
}
Report::Report(Data records, int totalRecords, float totalMinutes, float totalAmmount, string
fileName)
{
setTotalRecords(totalRecords);
setTotalMinutes(totalMinutes);
setTotalAmmount(totalAmmount);
setFileName(fileName);
}
void Report::addRecord(const Data & unData)
{
Data *records;
records = new Data[this->totalRecords + 1];
for (int i = 0;i < this->totalRecords;i++)
{
records[this->totalRecords] = unData;
delete[](this->records);
this->records = records;
++(this->records);
}
}
Report::Report(const Report & unReport)
{
this->records = NULL;
totalRecords = unReport.totalRecords;
totalMinutes = unReport.totalMinutes;
totalAmmount = unReport.totalAmmount;
fileName = unReport.fileName;
(*this) = unReport;
}
Report::~Report()
{
delete[](this->records);
}
void Report::setTotalRecords(int totalRecords)
{
this->totalRecords = totalRecords;
}
void Report::setTotalAmmount(float totalAmmount)
{
this->totalAmmount = totalAmmount;
}
void Report::setTotalMinutes(float totalMinutes)
{
this->totalMinutes = totalMinutes;
}
void Report::setFileName(string fileName)
{
this->fileName = fileName;
}
const Data & Report::operator[](int indice)const
{
return((this->records)[indice]);
}
Data Report::getRecords()const
{
for (int i = 0;i < totalRecords;i++)
{
return (records[i]);
}
}
int Report::getTotalRecords()const
{
return this->totalRecords;
}
float Report::getTotalAmmount()const
{
return this->totalAmmount;
}
float Report::getTotalMinutes()const
{
return this->totalMinutes;
}
string Report::getFileName()const
{
return this->fileName;
}
Report & Report::operator =(const Report & unReport)
{
delete[](this->records);
if (unReport.totalRecords > 0)
{
this->records = new Data[unReport.totalRecords];
for (int i = 0;i < unReport.totalRecords;i++)
{
(this->records[i] = (unReport.records)[i]);
}
}
else
{
this->records = NULL;
}
this->totalAmmount = unReport.totalAmmount;
this->totalMinutes = unReport.totalMinutes;
this->fileName = unReport.fileName;
return (*this);
}
bool Report::operator ==(const Report & unReport)const
{
bool record = false;
for (int i = 0;i < unReport.totalRecords;i++)
{
if (records[i] == unReport.records[i])
{
record = true;
}
return record;
}
return (this->totalRecords == unReport.totalRecords && this->totalAmmount ==
unReport.totalAmmount &&
this->totalMinutes == unReport.totalMinutes && this->fileName == unReport.fileName);
}
ostream & operator <<(ostream & os, const Report & unReport)
{
for (int i = 0; i < unReport.totalRecords;i++)
{
os << "Record number is: " << unReport.records[i] << endl;
}
return os;
}
istream & operator >>(istream & is, Report & unReport)
{
cout << "Enter record:" << unReport.records << endl;;
cout << "Total Records are: ";
is >> unReport.totalRecords;
cout << "Total Ammount: ";
is >> unReport.totalAmmount;
cout << "Total Minutes:";
is >> unReport.totalMinutes;
cout << "File name is: ";
is >> unReport.fileName;
return is;
}
Report.h
#pragma once
#include"Data.h"
#include
#include
using namespace std;
class Report
{
private:
Data *records;
int totalRecords;
float totalMinutes;
float totalAmmount;
string fileName;
public:
Report();
Report(Data records,int totalRecords, float totalMinutes, float totalAmmount, string
fileName);
Report(const Report & unReport);
~Report();
void addRecord(const Data & unData);
void setTotalRecords(int totalRecords);
void setTotalMinutes(float totalMinutes);
void setTotalAmmount(float totalAmmount);
void setFileName(string fileName);
const Data & operator[](int indice)const;
Data getRecords()const;
int getTotalRecords()const;
float getTotalMinutes()const;
float getTotalAmmount()const;
string getFileName()const;
Report & operator = (const Report & unReport);
bool operator ==(const Report & unReport)const;
friend ostream & operator<<(ostream & os, const Report & unReport);
friend istream & operator>>(istream & is, Report & unReport);
};

More Related Content

Similar to #include iostream #includeData.h #includePerson.h#in.pdf

Can you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdfCan you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdfaksachdevahosymills
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfHIMANSUKUMAR12
 
C++, Implement the class BinarySearchTree, as given in listing 16-4 .pdf
C++, Implement the class BinarySearchTree, as given in listing 16-4 .pdfC++, Implement the class BinarySearchTree, as given in listing 16-4 .pdf
C++, Implement the class BinarySearchTree, as given in listing 16-4 .pdfrohit219406
 
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docxRightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docxjoellemurphey
 
include ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfinclude ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfnaslin841216
 
Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Abdul Samee
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxssuser454af01
 
include ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfinclude ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfaathmiboutique
 
This is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfThis is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfinfo334223
 
I have the following code and I need to know why I am receiving the .pdf
I have the following code and I need to know why I am receiving the .pdfI have the following code and I need to know why I am receiving the .pdf
I have the following code and I need to know why I am receiving the .pdfezzi552
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programmingPrabhu Govind
 
Use the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdfUse the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdfsales87
 

Similar to #include iostream #includeData.h #includePerson.h#in.pdf (20)

Can you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdfCan you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdf
 
12
1212
12
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
 
C++, Implement the class BinarySearchTree, as given in listing 16-4 .pdf
C++, Implement the class BinarySearchTree, as given in listing 16-4 .pdfC++, Implement the class BinarySearchTree, as given in listing 16-4 .pdf
C++, Implement the class BinarySearchTree, as given in listing 16-4 .pdf
 
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docxRightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
 
include ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfinclude ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdf
 
COW
COWCOW
COW
 
Gps c
Gps cGps c
Gps c
 
Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
 
include ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfinclude ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdf
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
This is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfThis is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdf
 
I have the following code and I need to know why I am receiving the .pdf
I have the following code and I need to know why I am receiving the .pdfI have the following code and I need to know why I am receiving the .pdf
I have the following code and I need to know why I am receiving the .pdf
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programming
 
Use the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdfUse the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdf
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
 
Class ‘increment’
Class ‘increment’Class ‘increment’
Class ‘increment’
 
Day 1
Day 1Day 1
Day 1
 

More from annucommunication1

4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf
4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf
4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdfannucommunication1
 
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdfannucommunication1
 
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdfannucommunication1
 
package patienttest;import java.util.Comparator; import java..pdf
 package patienttest;import java.util.Comparator; import java..pdf package patienttest;import java.util.Comparator; import java..pdf
package patienttest;import java.util.Comparator; import java..pdfannucommunication1
 
will result in the formation of a soluble complex.pdf
                     will result in the formation of a soluble complex.pdf                     will result in the formation of a soluble complex.pdf
will result in the formation of a soluble complex.pdfannucommunication1
 
What types of elements are involved in metallic b.pdf
                     What types of elements are involved in metallic b.pdf                     What types of elements are involved in metallic b.pdf
What types of elements are involved in metallic b.pdfannucommunication1
 
The correct statements are When two atoms of app.pdf
                     The correct statements are  When two atoms of app.pdf                     The correct statements are  When two atoms of app.pdf
The correct statements are When two atoms of app.pdfannucommunication1
 
One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf
                     One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf                     One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf
One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdfannucommunication1
 
Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf
                     Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf                     Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf
Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdfannucommunication1
 
moles of CO2 = moles of NaHCO3 = 284 =0.0238 .pdf
                     moles of CO2 = moles of NaHCO3 = 284 =0.0238    .pdf                     moles of CO2 = moles of NaHCO3 = 284 =0.0238    .pdf
moles of CO2 = moles of NaHCO3 = 284 =0.0238 .pdfannucommunication1
 
Eukaryotic Chromosome Structure The length of DN.pdf
                     Eukaryotic Chromosome Structure  The length of DN.pdf                     Eukaryotic Chromosome Structure  The length of DN.pdf
Eukaryotic Chromosome Structure The length of DN.pdfannucommunication1
 
Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf
                     Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf                     Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf
Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdfannucommunication1
 
The various ways to finance a project are 1)Debt financing-One ca.pdf
The various ways to finance a project are 1)Debt financing-One ca.pdfThe various ways to finance a project are 1)Debt financing-One ca.pdf
The various ways to finance a project are 1)Debt financing-One ca.pdfannucommunication1
 
boiling point 1-propanol propanone note there.pdf
                     boiling point 1-propanol  propanone note there.pdf                     boiling point 1-propanol  propanone note there.pdf
boiling point 1-propanol propanone note there.pdfannucommunication1
 
The organs of urinary system includesPaired kidneys, paired ureter.pdf
The organs of urinary system includesPaired kidneys, paired ureter.pdfThe organs of urinary system includesPaired kidneys, paired ureter.pdf
The organs of urinary system includesPaired kidneys, paired ureter.pdfannucommunication1
 
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdf
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdfThe incorrect statement ise. Glucose is a stereoisomer of ribose..pdf
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdfannucommunication1
 
The answer is a. The intermolecular forces are much greater in wate.pdf
The answer is a. The intermolecular forces are much greater in wate.pdfThe answer is a. The intermolecular forces are much greater in wate.pdf
The answer is a. The intermolecular forces are much greater in wate.pdfannucommunication1
 

More from annucommunication1 (20)

4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf
4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf
4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf
 
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf
 
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf
 
package patienttest;import java.util.Comparator; import java..pdf
 package patienttest;import java.util.Comparator; import java..pdf package patienttest;import java.util.Comparator; import java..pdf
package patienttest;import java.util.Comparator; import java..pdf
 
ZnO + H2O = Zn(OH)2 .pdf
                     ZnO + H2O = Zn(OH)2                             .pdf                     ZnO + H2O = Zn(OH)2                             .pdf
ZnO + H2O = Zn(OH)2 .pdf
 
will result in the formation of a soluble complex.pdf
                     will result in the formation of a soluble complex.pdf                     will result in the formation of a soluble complex.pdf
will result in the formation of a soluble complex.pdf
 
What types of elements are involved in metallic b.pdf
                     What types of elements are involved in metallic b.pdf                     What types of elements are involved in metallic b.pdf
What types of elements are involved in metallic b.pdf
 
The correct statements are When two atoms of app.pdf
                     The correct statements are  When two atoms of app.pdf                     The correct statements are  When two atoms of app.pdf
The correct statements are When two atoms of app.pdf
 
Sure can There you go. .pdf
                     Sure can  There you go.                         .pdf                     Sure can  There you go.                         .pdf
Sure can There you go. .pdf
 
One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf
                     One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf                     One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf
One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf
 
Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf
                     Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf                     Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf
Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf
 
moles of CO2 = moles of NaHCO3 = 284 =0.0238 .pdf
                     moles of CO2 = moles of NaHCO3 = 284 =0.0238    .pdf                     moles of CO2 = moles of NaHCO3 = 284 =0.0238    .pdf
moles of CO2 = moles of NaHCO3 = 284 =0.0238 .pdf
 
Eukaryotic Chromosome Structure The length of DN.pdf
                     Eukaryotic Chromosome Structure  The length of DN.pdf                     Eukaryotic Chromosome Structure  The length of DN.pdf
Eukaryotic Chromosome Structure The length of DN.pdf
 
Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf
                     Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf                     Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf
Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf
 
D. is correct. Solution .pdf
                     D. is correct.  Solution                     .pdf                     D. is correct.  Solution                     .pdf
D. is correct. Solution .pdf
 
The various ways to finance a project are 1)Debt financing-One ca.pdf
The various ways to finance a project are 1)Debt financing-One ca.pdfThe various ways to finance a project are 1)Debt financing-One ca.pdf
The various ways to finance a project are 1)Debt financing-One ca.pdf
 
boiling point 1-propanol propanone note there.pdf
                     boiling point 1-propanol  propanone note there.pdf                     boiling point 1-propanol  propanone note there.pdf
boiling point 1-propanol propanone note there.pdf
 
The organs of urinary system includesPaired kidneys, paired ureter.pdf
The organs of urinary system includesPaired kidneys, paired ureter.pdfThe organs of urinary system includesPaired kidneys, paired ureter.pdf
The organs of urinary system includesPaired kidneys, paired ureter.pdf
 
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdf
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdfThe incorrect statement ise. Glucose is a stereoisomer of ribose..pdf
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdf
 
The answer is a. The intermolecular forces are much greater in wate.pdf
The answer is a. The intermolecular forces are much greater in wate.pdfThe answer is a. The intermolecular forces are much greater in wate.pdf
The answer is a. The intermolecular forces are much greater in wate.pdf
 

Recently uploaded

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 

Recently uploaded (20)

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 

#include iostream #includeData.h #includePerson.h#in.pdf

  • 1. #include #include"Data.h" #include"Person.h" #include"Report.h" #include #include #include "Menu.h" using namespace std; /* Programmers: Javier A. Molina, Eduardo Bonnet Students #:79249 */ int main() { int cnt; int idx; string fileName; Report * telefonia; Menu menu("Reports"); bool fileNameExists(string fileName); Report * addReport(Report * reports, int & totalReports); Report * delReport(Report * reports, int & totalReports, int idx); int displayReports(Report * reports, int totalReports); menu.addItem("New report"); menu.addItem("Delete a report"); menu.addItem("Display a report"); cnt = 0; telefonia = NULL; do { cout << menu; cin >> menu; //cls(); switch (menu.getOption()) { case 1: cout << "Enter report name (TE?????): ";
  • 2. cin >> fileName; if (fileNameExists(fileName + ".tel")) { telefonia = addReport(telefonia, cnt); idx = cnt - 1; telefonia[idx].setFileName(fileName); // telefonia[idx].loadReport(); } else { cls(); cerr << "Error: Report name '" << fileName << "' does not exists! "; //pause(); } break; case 2: if (telefonia != NULL) { do { cls(); cout << "Delete a Report: "; idx = displayReports(telefonia, cnt); if (between(idx, 0, cnt - 1)) { cls(); telefonia = delReport(telefonia, cnt, idx); idx = 0; // pause(); } } while (idx != cnt); } else { cerr << "No reports available for deleting! "; //pause(); } break; case 3: char ans; if (telefonia != NULL) { do {
  • 3. // cls(); cout << "Display/Filed a Report: "; idx = displayReports(telefonia, cnt); if (between(idx, 0, cnt - 1)) { // cls(); cout << "Would you like the report to be display otherwise save into a file? "; cin >> ans; cls(); cin.ignore(); if (upper(ans) == 'Y') { cout << telefonia[idx] << endl; } else { //telefonia[idx].saveReport(); cout << "Report '" << telefonia[idx].getFileName() << "' saved as '" << telefonia[idx].getFileName() << ".rep'. "; } //pause(); } } while (idx != cnt); } else { cerr << "No reports available for displaying! "; // pause(); } break; case 4: cout << "Thanks for using Telefonia Reports System!!! "; break; } } while (menu.getLast() != menu.getOption()); delete[] telefonia; return 0; } //Funcion que verifica si existe un archivo en disco bool fileNameExists(string fileName) {
  • 4. ifstream fin(fileName.c_str()); bool exists = !(fin.fail()); if (exists) fin.close(); return(exists); } //Anade dinamicamente objetos tipo Report al arreglo reports Report * addReport(Report * reports, int & totalReports) { if (totalReports == 0) { reports = new Report[1]; } else { Report * tmp = new Report[totalReports]; for (int i = 0; i < totalReports; ++i) { tmp[i] = reports[i]; } delete[] reports; reports = new Report[totalReports + 1]; for (int i = 0; i < totalReports; ++i) { reports[i] = tmp[i]; } delete[] tmp; } totalReports++; return(reports); } //Borra objetos del arreglo reports segun el idx enviado Report * delReport(Report * reports, int & totalReports, int idx) { Report * tmp = new Report[totalReports - 1]; string fileName = reports[idx].getFileName(); for (int i = 0, j = 0; i < totalReports; ++i) { if (i == idx) continue; tmp[j] = reports[i]; j++; } delete[] reports; totalReports--;
  • 5. reports = new Report[totalReports]; for (int i = 0; i < totalReports; ++i) { reports[i] = tmp[i]; } delete[] tmp; cout << "Report '" << fileName << "' has been deleted! " << endl; if (totalReports == 0) reports = NULL; return(reports); } //Muestra en pantalla la lista de informes que se encuantran en memoria int displayReports(Report * reports, int totalReports) { int choice; int i; for (i = 0; i < totalReports; ++i) { cout << "t" << (i + 1) << ".) " << reports[i].getFileName() << endl; } cout << "t" << (i + 1) << ".) Return "; cout << " tChoice: "; cin >> choice; return (choice - 1); } Data.h #include #include #include #ifndef DATA_H #define DATA_H #include "Person.h" using namespace std; #pragma once //Trata de establecer coneccion entre la clase data y person, utilizando informacion de la clase person busca informacion de las llamadas hechas por el cliente //Person(client) con esto saca la informacion de los datos escritos en la clase class Data { private:
  • 6. Person client;//atributo de la clase person string callDate;//atributos esenciales de la clase Data bool longDistance; string timeCallBegin; string timeCallEnd; string callNoFrom; string callNoTo; public: Data();//default Data(Person client, string callDate, bool longDistance, string timeCallBegin, string timeCallEnd, string callNoFrom, string callNoTo);//parameter constructor Data(const Data & unData);//copy constructor ~Data();//destructor void setClient(const Person & client);//setters void setCallDate(string callDate); void setLongDistance(bool longDistance); void setTimeCallBegin(string timeCallBegin); void setTimeCallEnd(string timeCallEnd); void setCallNoFrom(string callNoFrom); void setCallNoTo(string callNoTo); Person getClient()const;//getters string getCallDate()const; bool getLongDistance()const; string getTimeCallBegin()const; string getTimeCallEnd()const; string getCallNoFrom()const; string getCallNoTo()const; Data & operator = (const Data & unData);//operador de asignar bool operator ==(const Data & unData)const;//operador de igualdad friend ostream & operator <<(ostream & output, const Data & unData);//friend operador, imprime valores friend istream & operator >>(istream & input, Data & unData);//friend operator, manipula los valores de los atributos }; #endif // DATA_H
  • 7. Data.cpp #include "Data.h" using namespace std; Data::Data()//default { setClient(Person(" "," "," "," ")); setCallDate(" ");//valores asignados por default setLongDistance(false); setTimeCallBegin(" "); setTimeCallEnd(" "); setCallNoFrom(" "); setCallNoTo(" "); } Data::Data (Person client, string callDate, bool longDistance, string timeCallBegin, string timeCallEnd, string callNoFrom, string callNoTo)//parameter constructor { setClient(client); setCallDate(callDate); setLongDistance(longDistance); setTimeCallBegin(timeCallBegin); setTimeCallEnd(timeCallEnd); setCallNoFrom(callNoFrom); setCallNoTo(callNoTo); } Data::Data(const Data & unData)//copy constructor { this->client = unData.client; this->callDate = unData.callDate; this->longDistance = unData.longDistance; this->timeCallBegin = unData.timeCallBegin; this->timeCallEnd = unData.timeCallEnd; this->callNoFrom = unData.callNoFrom; this->callNoTo = unData.callNoTo; } Data::~Data()//destructor {
  • 8. } void Data::setClient(const Person & client)//setters { this->client = client; } void Data::setCallDate(string callDate) { this->callDate = callDate; } void Data::setLongDistance(bool longDistance) { if (longDistance == 1)//verificacion del valor para clasificar en true or false { longDistance = true; this->longDistance = longDistance; } else { longDistance = false; this->longDistance = longDistance; } } void Data::setTimeCallBegin(string timeCallBegin) { this->timeCallBegin = timeCallBegin; } void Data::setTimeCallEnd(string timeCallEnd) { this->timeCallEnd = timeCallEnd; } void Data::setCallNoFrom(string callNoFrom) { this->callNoFrom = callNoFrom; } void Data::setCallNoTo(string callNoTo) {
  • 9. this->callNoTo = callNoTo; } Person Data::getClient()const//getters { return (this->client); } string Data::getCallDate()const { return (this->callDate); } bool Data::getLongDistance()const { return(this->longDistance); } string Data::getTimeCallBegin()const { return (this->timeCallBegin); } string Data::getTimeCallEnd()const { return (this->timeCallEnd); } string Data::getCallNoFrom()const { return (this->callNoFrom); } string Data::getCallNoTo()const { return(this->callNoTo); } Data & Data :: operator =(const Data & unData)//asigna los valores { this->client = unData.client; this->callDate = unData.callDate; this->longDistance = unData.longDistance; this->timeCallBegin = unData.timeCallBegin;
  • 10. this->timeCallEnd = unData.timeCallEnd; this->callNoFrom = unData.callNoFrom; this->callNoTo = unData.callNoTo; return (*this); } bool Data :: operator ==(const Data & unData)const//verificacion de igualdad de todos los valores { return (this->client == unData.client && this->callDate == unData.callDate && this- >longDistance == unData.longDistance && this->timeCallBegin == unData.timeCallBegin && this->timeCallEnd == unData.timeCallEnd && this->callNoFrom == unData.callNoFrom && this->callNoTo == unData.callNoTo); } ostream & operator <<(ostream & output, const Data & unData)//imprime valores { Person person; output << "Providing Client Information:" << endl; output << person.getFirstName(); output << person.getLastName(); output << person.getMiddleName(); output << person.getMaidenName(); output << endl << "Call Date: " << unData.callDate << endl; output << "longDistance Charge: " << unData.longDistance ? " Y " : " N ";//Yes or No question output << "Time Call Begin: " << unData.timeCallBegin; output << "Time Call End: " << unData.timeCallEnd; output << "Call # From: " << unData.callNoFrom; output << "Call # to: " << unData.callNoTo; return output; } istream & operator >>(istream & input, Data & unData)//pide valores { cout << "Client Information: " << endl; input >> unData.client; cout << "Call Date: " << endl;
  • 11. input >> unData.callDate; cout << " Long Distance: " << endl; input >> unData.longDistance; cout << " Time Call Begin: " << endl; input >> unData.timeCallBegin; cout << " Time Call End: " << endl; input >> unData.timeCallEnd; cout << " Call # From : " << endl; input >> unData.callNoFrom; cout << " Call # To: " << endl; input >> unData.callNoTo; return input; } Person.h #pragma once #include #include using namespace std; class Person { private: string firstName; string lastName; string middleName; string maidenName; public: Person(); Person(string firstName, string lastName, string middleName, string maidenName); Person(const Person & unPerson);//copy constructor ~Person();//destructor void setFirstName(string firsName);//setters void setLastName(string lastName); void setMiddleName(string middleName); void setMaidenName(string maidenName); string getFirstName()const;//getters
  • 12. string getLastName()const; string getMiddleName()const; string getMaidenName()const; Person & operator = (const Person & unPerson);//operador de asignar valores bool operator ==(const Person & unPerson)const;//operador de igualdad friend ostream & operator <<(ostream & output, const Person & unPerson);//friend operador que imprime friend istream & operator >>(istream & input, Person & unPerson);//friend operador que pide cambia valores }; Person.cpp #include "Person.h" using namespace std; Person::Person()//default cnstructor { firstName = (" ");//valores por default lastName =(" "); middleName =(" "); maidenName = (" "); } Person::Person(string firstName, string lastName, string middleName, string maidenName)//parameter { setFirstName(firstName);//nombrando las variables setLastName(lastName); setMiddleName(middleName); setMaidenName(maidenName); } Person::Person(const Person & unPerson)//copy { firstName = unPerson.firstName;//asignando variables lastName = unPerson.lastName; middleName = unPerson.middleName; maidenName = unPerson.maidenName; } Person::~Person()//destructor
  • 13. { } void Person::setFirstName(string firstName)//setters { this->firstName = firstName; } void Person::setLastName(string lastName) { this->lastName = lastName; } void Person::setMiddleName(string middleName) { this->middleName = middleName; } void Person::setMaidenName(string maidenName) { this->maidenName = maidenName; } string Person::getFirstName()const//getters { return (this->firstName); } string Person::getLastName()const { return (this->lastName); } string Person::getMiddleName()const { return (this->middleName); } string Person::getMaidenName()const { return (this->maidenName); } Person & Person:: operator =(const Person & unPerson)//operador que asigna valores {
  • 14. this->firstName = unPerson.firstName; this->lastName = unPerson.lastName; this->middleName = unPerson.middleName; this->maidenName = unPerson.maidenName; return (*this);//retorna todos los valores guardados } bool Person:: operator == (const Person & unPerson)const//operador de igualdad y comparacion de valores, verifica que sean iguales { return (this->firstName == unPerson.firstName && this->lastName == unPerson.lastName && this->middleName == unPerson.middleName && this->maidenName == unPerson.maidenName); } ostream & operator <<(ostream & output, const Person & unPerson)//imprime valores { output << " First Name: " << unPerson.firstName; output << " LastName: " << unPerson.lastName; output << "MiddleName: " << unPerson.middleName; output << " Maiden Name: " << unPerson.maidenName; return output; } istream & operator >>(istream & input, Person & unPerson)//cambia o pide valores { cout << " Please Enter First Name t Middle Name t Last Name t Maiden Name " << endl; input >> unPerson.firstName; input >> unPerson.middleName; input >> unPerson.lastName; input >> unPerson.maidenName; return input; } Menu.h #pragma once #include #include
  • 15. #include "MyLib.h" using namespace::std; #ifndef MENU_H #define MENU_H enum Choice { numeric, alpha }; enum Lang { eng, spa }; class Menu { private: string * items; string title; int totalItems; Lang lang; Choice choice; int option; flag validate; flag subMenu; public: Menu() { init(); } Menu(const char * title) { init(); this->title = title; } Menu(const Menu & aMenu) { init(); this->title = aMenu.title; if (!aMenu.isEmpty()) { for (int i = 0; i < aMenu.totalItems; ++i) { addItem(aMenu.items[i]); } this->choice = aMenu.choice; this->validate = aMenu.validate;
  • 16. this->subMenu = aMenu.subMenu; this->title = aMenu.title; } } void init() { this->items = NULL; this->totalItems = 0; this->lang = eng; this->choice = numeric; this->validate = false; this->subMenu = false; this->title = "Menu"; } ~Menu() { delete[] this->items; } bool isEmpty() const { return this->totalItems == 0; } void addItem(string item) { int idx = this->totalItems; string * tmp; int i; if (isEmpty()) { this->items = new string[1]; } else { tmp = new string[this->totalItems]; for (i = 0; i < this->totalItems; i++) { tmp[i] = this->items[i]; } delete[] this->items; this->items = new string[this->totalItems + 1];
  • 17. for (i = 0; i < this->totalItems; i++) { this->items[i] = tmp[i]; } delete[] tmp; } this->items[idx] = item; this->totalItems++; } bool check() { if (this->choice == alpha) { this->validate = between(char(option), 'A', char('A' + this->totalItems)); } else { this->validate = between(option, 1, this->totalItems + 1); } return this->validate; } void setChoice(Choice choice) { this->choice = choice; } void setOption(int option) { this->option = upper(option); check(); } void setLang(Lang lang) { this->lang = lang; } void setTitle(string title) { this->title = title; } void setSubMenu(flag subMenu) {
  • 18. subMenu = subMenu; } Lang getLanguage() const { return this->lang; } int getOption() const { return this->option; } int getLast() const { if (this->choice == alpha) { return char('A' + this->totalItems); } else { return this->totalItems + 1; } } friend ostream & operator <<(ostream & os, Menu & unMenu) { int i; char ch = 'a'; cls(); os << unMenu.title << endl << endl; for (i = 0; i < unMenu.totalItems; i++) { os << "t"; if (unMenu.choice == alpha) os << char(ch + i); else os << i + 1; os << ".) " << unMenu.items[i] << endl; } os << "t"; if (unMenu.choice == alpha) os << char(ch + i); else os << i + 1; os << ".) "; if (unMenu.lang == eng) { if (unMenu.subMenu) os << "Return";
  • 19. else os << "Exit"; os << " Choose: "; } else { if (unMenu.subMenu) os << "Regresar"; else os << "Salir"; os << " Opcion: "; } return os; } friend istream & operator >>(istream & in, Menu & unMenu) { do { char opt; in >> opt; unMenu.setOption((unMenu.choice == alpha ? opt : opt - '0')); if (!unMenu.check()) { cerr << " Error: Wrong choice!!! "; pause(); cout << unMenu; } } while (!unMenu.check()); return in; } }; #endif // MENU_H mylib.h #pragma once #include #include using namespace::std; #ifndef MYLIB_H
  • 20. #define MYLIB_H typedef bool flag; #ifdef WINDOWS #define cls() system("cls") #define pause() system("pause") #elif windows #define cls() system("cls") #define pause() system("pause") #elif LINUX #define cls() system("clear") #define pause() system("sleep 3") #elif linux #define cls() system("clear") #define pause() system("sleep 3") #else #define cls() { cerr << "CLS: Unknown OS!!! "; } #define pause() { cerr << "PAUSE: Unknown OS!!! "; } #endif #define between(x, y, z) ((x >= y && x <= z)? true : false) #define upper(x) (between(x, 'A', 'Z')? x : (between(x, 'a', 'z')? x - 'a' + 'A' : x)) #define lower(x) (between(x, 'a', 'z')? x : x - 'A' + 'a') #endif // MYLIB_H DataParser.h #include "DataParser.h" #include #include"Person.h" #include"Report.h" DataParser::DataParser() { record; } DataParser::DataParser(string line) { parseLine(line); } DataParser::DataParser(const DataParser & unDataParser)
  • 21. { this->record = unDataParser.record; this->fecha = unDataParser.fecha; } DataParser::~DataParser() { } Data DataParser::parseLine(string line) { Person client;//atributos de clase Person y Data string callDate; bool longDistance; string timeCallBegin; string timeCallEnd; string callNoFrom; string callNoTo; string firstName; string lastName; string middleName; string maidenName; //substr demostrara en que linea firstName = line.substr(0, 25); middleName = line.substr(25, 25); lastName = line.substr(50, 50); maidenName = line.substr(100, 50); callDate = line.substr(150, 8); if (line.substr(158, 1) == "Y")//yes or no longDistance = true; else longDistance = false; timeCallBegin = line.substr(159, 6); timeCallEnd = line.substr(165, 6); callNoFrom = line.substr(171, 10); callNoTo = line.substr(181, 10); record.setClient(Person(firstName, middleName, lastName, maidenName));
  • 22. record.setCallDate(callDate); record.setLongDistance(longDistance); record.setTimeCallBegin(timeCallBegin); record.setTimeCallEnd(timeCallEnd); record.setCallNoFrom(callNoFrom); record.setCallNoTo(callNoTo); return record; } void DataParser::setRecord(string line) { parseLine(line); } Data DataParser::getRecord() const { return (this->record); } string DataParser::date(string date) { string fecha; fecha = date.substr(191, 2) + "/" + date.substr(193, 2) + "/" + date.substr(195, 4); return fecha; } void DataParser::setFecha(int fecha) { this->fecha = fecha; } int DataParser::getFecha()const { return(this->fecha); } DataParser.h #pragma once #include #include #include "Data.h" using namespace std;
  • 23. class DataParser { private: Data record; int fecha; public: DataParser(); DataParser(string line); DataParser(const DataParser & unDataPaser); ~DataParser(); void setRecord(string line); void setFecha(int fecha); int getFecha()const; Data getRecord()const; Data parseLine(string line); string date(string date); // friend ostream & operator <<(ostream & os, const DataParser & unDataParser); // friend istream & operator >> (istream & is, DataParser & unDataParser); }; Report.cpp #include "Report.h" Report::Report() { records = NULL; totalRecords = 0; totalMinutes = 0.0; totalAmmount = 0.0; fileName=(" "); } Report::Report(Data records, int totalRecords, float totalMinutes, float totalAmmount, string fileName) { setTotalRecords(totalRecords); setTotalMinutes(totalMinutes); setTotalAmmount(totalAmmount);
  • 24. setFileName(fileName); } void Report::addRecord(const Data & unData) { Data *records; records = new Data[this->totalRecords + 1]; for (int i = 0;i < this->totalRecords;i++) { records[this->totalRecords] = unData; delete[](this->records); this->records = records; ++(this->records); } } Report::Report(const Report & unReport) { this->records = NULL; totalRecords = unReport.totalRecords; totalMinutes = unReport.totalMinutes; totalAmmount = unReport.totalAmmount; fileName = unReport.fileName; (*this) = unReport; } Report::~Report() { delete[](this->records); } void Report::setTotalRecords(int totalRecords) { this->totalRecords = totalRecords; } void Report::setTotalAmmount(float totalAmmount) { this->totalAmmount = totalAmmount; } void Report::setTotalMinutes(float totalMinutes)
  • 25. { this->totalMinutes = totalMinutes; } void Report::setFileName(string fileName) { this->fileName = fileName; } const Data & Report::operator[](int indice)const { return((this->records)[indice]); } Data Report::getRecords()const { for (int i = 0;i < totalRecords;i++) { return (records[i]); } } int Report::getTotalRecords()const { return this->totalRecords; } float Report::getTotalAmmount()const { return this->totalAmmount; } float Report::getTotalMinutes()const { return this->totalMinutes; } string Report::getFileName()const { return this->fileName; } Report & Report::operator =(const Report & unReport) {
  • 26. delete[](this->records); if (unReport.totalRecords > 0) { this->records = new Data[unReport.totalRecords]; for (int i = 0;i < unReport.totalRecords;i++) { (this->records[i] = (unReport.records)[i]); } } else { this->records = NULL; } this->totalAmmount = unReport.totalAmmount; this->totalMinutes = unReport.totalMinutes; this->fileName = unReport.fileName; return (*this); } bool Report::operator ==(const Report & unReport)const { bool record = false; for (int i = 0;i < unReport.totalRecords;i++) { if (records[i] == unReport.records[i]) { record = true; } return record; } return (this->totalRecords == unReport.totalRecords && this->totalAmmount == unReport.totalAmmount && this->totalMinutes == unReport.totalMinutes && this->fileName == unReport.fileName); } ostream & operator <<(ostream & os, const Report & unReport) { for (int i = 0; i < unReport.totalRecords;i++)
  • 27. { os << "Record number is: " << unReport.records[i] << endl; } return os; } istream & operator >>(istream & is, Report & unReport) { cout << "Enter record:" << unReport.records << endl;; cout << "Total Records are: "; is >> unReport.totalRecords; cout << "Total Ammount: "; is >> unReport.totalAmmount; cout << "Total Minutes:"; is >> unReport.totalMinutes; cout << "File name is: "; is >> unReport.fileName; return is; } Report.h #pragma once #include"Data.h" #include #include using namespace std; class Report { private: Data *records; int totalRecords; float totalMinutes; float totalAmmount; string fileName; public: Report(); Report(Data records,int totalRecords, float totalMinutes, float totalAmmount, string fileName);
  • 28. Report(const Report & unReport); ~Report(); void addRecord(const Data & unData); void setTotalRecords(int totalRecords); void setTotalMinutes(float totalMinutes); void setTotalAmmount(float totalAmmount); void setFileName(string fileName); const Data & operator[](int indice)const; Data getRecords()const; int getTotalRecords()const; float getTotalMinutes()const; float getTotalAmmount()const; string getFileName()const; Report & operator = (const Report & unReport); bool operator ==(const Report & unReport)const; friend ostream & operator<<(ostream & os, const Report & unReport); friend istream & operator>>(istream & is, Report & unReport); }; Solution #include #include"Data.h" #include"Person.h" #include"Report.h" #include #include #include "Menu.h" using namespace std; /* Programmers: Javier A. Molina, Eduardo Bonnet Students #:79249 */ int main() {
  • 29. int cnt; int idx; string fileName; Report * telefonia; Menu menu("Reports"); bool fileNameExists(string fileName); Report * addReport(Report * reports, int & totalReports); Report * delReport(Report * reports, int & totalReports, int idx); int displayReports(Report * reports, int totalReports); menu.addItem("New report"); menu.addItem("Delete a report"); menu.addItem("Display a report"); cnt = 0; telefonia = NULL; do { cout << menu; cin >> menu; //cls(); switch (menu.getOption()) { case 1: cout << "Enter report name (TE?????): "; cin >> fileName; if (fileNameExists(fileName + ".tel")) { telefonia = addReport(telefonia, cnt); idx = cnt - 1; telefonia[idx].setFileName(fileName); // telefonia[idx].loadReport(); } else { cls(); cerr << "Error: Report name '" << fileName << "' does not exists! "; //pause(); } break; case 2: if (telefonia != NULL) {
  • 30. do { cls(); cout << "Delete a Report: "; idx = displayReports(telefonia, cnt); if (between(idx, 0, cnt - 1)) { cls(); telefonia = delReport(telefonia, cnt, idx); idx = 0; // pause(); } } while (idx != cnt); } else { cerr << "No reports available for deleting! "; //pause(); } break; case 3: char ans; if (telefonia != NULL) { do { // cls(); cout << "Display/Filed a Report: "; idx = displayReports(telefonia, cnt); if (between(idx, 0, cnt - 1)) { // cls(); cout << "Would you like the report to be display otherwise save into a file? "; cin >> ans; cls(); cin.ignore(); if (upper(ans) == 'Y') { cout << telefonia[idx] << endl; } else { //telefonia[idx].saveReport(); cout << "Report '" << telefonia[idx].getFileName() << "' saved as '" <<
  • 31. telefonia[idx].getFileName() << ".rep'. "; } //pause(); } } while (idx != cnt); } else { cerr << "No reports available for displaying! "; // pause(); } break; case 4: cout << "Thanks for using Telefonia Reports System!!! "; break; } } while (menu.getLast() != menu.getOption()); delete[] telefonia; return 0; } //Funcion que verifica si existe un archivo en disco bool fileNameExists(string fileName) { ifstream fin(fileName.c_str()); bool exists = !(fin.fail()); if (exists) fin.close(); return(exists); } //Anade dinamicamente objetos tipo Report al arreglo reports Report * addReport(Report * reports, int & totalReports) { if (totalReports == 0) { reports = new Report[1]; } else { Report * tmp = new Report[totalReports]; for (int i = 0; i < totalReports; ++i) { tmp[i] = reports[i]; }
  • 32. delete[] reports; reports = new Report[totalReports + 1]; for (int i = 0; i < totalReports; ++i) { reports[i] = tmp[i]; } delete[] tmp; } totalReports++; return(reports); } //Borra objetos del arreglo reports segun el idx enviado Report * delReport(Report * reports, int & totalReports, int idx) { Report * tmp = new Report[totalReports - 1]; string fileName = reports[idx].getFileName(); for (int i = 0, j = 0; i < totalReports; ++i) { if (i == idx) continue; tmp[j] = reports[i]; j++; } delete[] reports; totalReports--; reports = new Report[totalReports]; for (int i = 0; i < totalReports; ++i) { reports[i] = tmp[i]; } delete[] tmp; cout << "Report '" << fileName << "' has been deleted! " << endl; if (totalReports == 0) reports = NULL; return(reports); } //Muestra en pantalla la lista de informes que se encuantran en memoria int displayReports(Report * reports, int totalReports) { int choice; int i; for (i = 0; i < totalReports; ++i) { cout << "t" << (i + 1) << ".) " << reports[i].getFileName() << endl;
  • 33. } cout << "t" << (i + 1) << ".) Return "; cout << " tChoice: "; cin >> choice; return (choice - 1); } Data.h #include #include #include #ifndef DATA_H #define DATA_H #include "Person.h" using namespace std; #pragma once //Trata de establecer coneccion entre la clase data y person, utilizando informacion de la clase person busca informacion de las llamadas hechas por el cliente //Person(client) con esto saca la informacion de los datos escritos en la clase class Data { private: Person client;//atributo de la clase person string callDate;//atributos esenciales de la clase Data bool longDistance; string timeCallBegin; string timeCallEnd; string callNoFrom; string callNoTo; public: Data();//default Data(Person client, string callDate, bool longDistance, string timeCallBegin, string timeCallEnd, string callNoFrom, string callNoTo);//parameter constructor Data(const Data & unData);//copy constructor ~Data();//destructor void setClient(const Person & client);//setters void setCallDate(string callDate);
  • 34. void setLongDistance(bool longDistance); void setTimeCallBegin(string timeCallBegin); void setTimeCallEnd(string timeCallEnd); void setCallNoFrom(string callNoFrom); void setCallNoTo(string callNoTo); Person getClient()const;//getters string getCallDate()const; bool getLongDistance()const; string getTimeCallBegin()const; string getTimeCallEnd()const; string getCallNoFrom()const; string getCallNoTo()const; Data & operator = (const Data & unData);//operador de asignar bool operator ==(const Data & unData)const;//operador de igualdad friend ostream & operator <<(ostream & output, const Data & unData);//friend operador, imprime valores friend istream & operator >>(istream & input, Data & unData);//friend operator, manipula los valores de los atributos }; #endif // DATA_H Data.cpp #include "Data.h" using namespace std; Data::Data()//default { setClient(Person(" "," "," "," ")); setCallDate(" ");//valores asignados por default setLongDistance(false); setTimeCallBegin(" "); setTimeCallEnd(" "); setCallNoFrom(" "); setCallNoTo(" "); } Data::Data (Person client, string callDate, bool longDistance, string timeCallBegin, string timeCallEnd, string callNoFrom, string callNoTo)//parameter constructor
  • 35. { setClient(client); setCallDate(callDate); setLongDistance(longDistance); setTimeCallBegin(timeCallBegin); setTimeCallEnd(timeCallEnd); setCallNoFrom(callNoFrom); setCallNoTo(callNoTo); } Data::Data(const Data & unData)//copy constructor { this->client = unData.client; this->callDate = unData.callDate; this->longDistance = unData.longDistance; this->timeCallBegin = unData.timeCallBegin; this->timeCallEnd = unData.timeCallEnd; this->callNoFrom = unData.callNoFrom; this->callNoTo = unData.callNoTo; } Data::~Data()//destructor { } void Data::setClient(const Person & client)//setters { this->client = client; } void Data::setCallDate(string callDate) { this->callDate = callDate; } void Data::setLongDistance(bool longDistance) { if (longDistance == 1)//verificacion del valor para clasificar en true or false { longDistance = true; this->longDistance = longDistance;
  • 36. } else { longDistance = false; this->longDistance = longDistance; } } void Data::setTimeCallBegin(string timeCallBegin) { this->timeCallBegin = timeCallBegin; } void Data::setTimeCallEnd(string timeCallEnd) { this->timeCallEnd = timeCallEnd; } void Data::setCallNoFrom(string callNoFrom) { this->callNoFrom = callNoFrom; } void Data::setCallNoTo(string callNoTo) { this->callNoTo = callNoTo; } Person Data::getClient()const//getters { return (this->client); } string Data::getCallDate()const { return (this->callDate); } bool Data::getLongDistance()const { return(this->longDistance); } string Data::getTimeCallBegin()const
  • 37. { return (this->timeCallBegin); } string Data::getTimeCallEnd()const { return (this->timeCallEnd); } string Data::getCallNoFrom()const { return (this->callNoFrom); } string Data::getCallNoTo()const { return(this->callNoTo); } Data & Data :: operator =(const Data & unData)//asigna los valores { this->client = unData.client; this->callDate = unData.callDate; this->longDistance = unData.longDistance; this->timeCallBegin = unData.timeCallBegin; this->timeCallEnd = unData.timeCallEnd; this->callNoFrom = unData.callNoFrom; this->callNoTo = unData.callNoTo; return (*this); } bool Data :: operator ==(const Data & unData)const//verificacion de igualdad de todos los valores { return (this->client == unData.client && this->callDate == unData.callDate && this- >longDistance == unData.longDistance && this->timeCallBegin == unData.timeCallBegin && this->timeCallEnd == unData.timeCallEnd && this->callNoFrom == unData.callNoFrom && this->callNoTo == unData.callNoTo); } ostream & operator <<(ostream & output, const Data & unData)//imprime valores
  • 38. { Person person; output << "Providing Client Information:" << endl; output << person.getFirstName(); output << person.getLastName(); output << person.getMiddleName(); output << person.getMaidenName(); output << endl << "Call Date: " << unData.callDate << endl; output << "longDistance Charge: " << unData.longDistance ? " Y " : " N ";//Yes or No question output << "Time Call Begin: " << unData.timeCallBegin; output << "Time Call End: " << unData.timeCallEnd; output << "Call # From: " << unData.callNoFrom; output << "Call # to: " << unData.callNoTo; return output; } istream & operator >>(istream & input, Data & unData)//pide valores { cout << "Client Information: " << endl; input >> unData.client; cout << "Call Date: " << endl; input >> unData.callDate; cout << " Long Distance: " << endl; input >> unData.longDistance; cout << " Time Call Begin: " << endl; input >> unData.timeCallBegin; cout << " Time Call End: " << endl; input >> unData.timeCallEnd; cout << " Call # From : " << endl; input >> unData.callNoFrom; cout << " Call # To: " << endl; input >> unData.callNoTo; return input; } Person.h
  • 39. #pragma once #include #include using namespace std; class Person { private: string firstName; string lastName; string middleName; string maidenName; public: Person(); Person(string firstName, string lastName, string middleName, string maidenName); Person(const Person & unPerson);//copy constructor ~Person();//destructor void setFirstName(string firsName);//setters void setLastName(string lastName); void setMiddleName(string middleName); void setMaidenName(string maidenName); string getFirstName()const;//getters string getLastName()const; string getMiddleName()const; string getMaidenName()const; Person & operator = (const Person & unPerson);//operador de asignar valores bool operator ==(const Person & unPerson)const;//operador de igualdad friend ostream & operator <<(ostream & output, const Person & unPerson);//friend operador que imprime friend istream & operator >>(istream & input, Person & unPerson);//friend operador que pide cambia valores }; Person.cpp #include "Person.h" using namespace std; Person::Person()//default cnstructor {
  • 40. firstName = (" ");//valores por default lastName =(" "); middleName =(" "); maidenName = (" "); } Person::Person(string firstName, string lastName, string middleName, string maidenName)//parameter { setFirstName(firstName);//nombrando las variables setLastName(lastName); setMiddleName(middleName); setMaidenName(maidenName); } Person::Person(const Person & unPerson)//copy { firstName = unPerson.firstName;//asignando variables lastName = unPerson.lastName; middleName = unPerson.middleName; maidenName = unPerson.maidenName; } Person::~Person()//destructor { } void Person::setFirstName(string firstName)//setters { this->firstName = firstName; } void Person::setLastName(string lastName) { this->lastName = lastName; } void Person::setMiddleName(string middleName) { this->middleName = middleName; } void Person::setMaidenName(string maidenName)
  • 41. { this->maidenName = maidenName; } string Person::getFirstName()const//getters { return (this->firstName); } string Person::getLastName()const { return (this->lastName); } string Person::getMiddleName()const { return (this->middleName); } string Person::getMaidenName()const { return (this->maidenName); } Person & Person:: operator =(const Person & unPerson)//operador que asigna valores { this->firstName = unPerson.firstName; this->lastName = unPerson.lastName; this->middleName = unPerson.middleName; this->maidenName = unPerson.maidenName; return (*this);//retorna todos los valores guardados } bool Person:: operator == (const Person & unPerson)const//operador de igualdad y comparacion de valores, verifica que sean iguales { return (this->firstName == unPerson.firstName && this->lastName == unPerson.lastName && this->middleName == unPerson.middleName && this->maidenName == unPerson.maidenName); } ostream & operator <<(ostream & output, const Person & unPerson)//imprime valores
  • 42. { output << " First Name: " << unPerson.firstName; output << " LastName: " << unPerson.lastName; output << "MiddleName: " << unPerson.middleName; output << " Maiden Name: " << unPerson.maidenName; return output; } istream & operator >>(istream & input, Person & unPerson)//cambia o pide valores { cout << " Please Enter First Name t Middle Name t Last Name t Maiden Name " << endl; input >> unPerson.firstName; input >> unPerson.middleName; input >> unPerson.lastName; input >> unPerson.maidenName; return input; } Menu.h #pragma once #include #include #include "MyLib.h" using namespace::std; #ifndef MENU_H #define MENU_H enum Choice { numeric, alpha }; enum Lang { eng, spa }; class Menu { private: string * items; string title; int totalItems; Lang lang; Choice choice; int option; flag validate;
  • 43. flag subMenu; public: Menu() { init(); } Menu(const char * title) { init(); this->title = title; } Menu(const Menu & aMenu) { init(); this->title = aMenu.title; if (!aMenu.isEmpty()) { for (int i = 0; i < aMenu.totalItems; ++i) { addItem(aMenu.items[i]); } this->choice = aMenu.choice; this->validate = aMenu.validate; this->subMenu = aMenu.subMenu; this->title = aMenu.title; } } void init() { this->items = NULL; this->totalItems = 0; this->lang = eng; this->choice = numeric; this->validate = false; this->subMenu = false; this->title = "Menu"; } ~Menu() {
  • 44. delete[] this->items; } bool isEmpty() const { return this->totalItems == 0; } void addItem(string item) { int idx = this->totalItems; string * tmp; int i; if (isEmpty()) { this->items = new string[1]; } else { tmp = new string[this->totalItems]; for (i = 0; i < this->totalItems; i++) { tmp[i] = this->items[i]; } delete[] this->items; this->items = new string[this->totalItems + 1]; for (i = 0; i < this->totalItems; i++) { this->items[i] = tmp[i]; } delete[] tmp; } this->items[idx] = item; this->totalItems++; } bool check() { if (this->choice == alpha) { this->validate = between(char(option), 'A', char('A' + this->totalItems)); } else { this->validate = between(option, 1, this->totalItems + 1);
  • 45. } return this->validate; } void setChoice(Choice choice) { this->choice = choice; } void setOption(int option) { this->option = upper(option); check(); } void setLang(Lang lang) { this->lang = lang; } void setTitle(string title) { this->title = title; } void setSubMenu(flag subMenu) { subMenu = subMenu; } Lang getLanguage() const { return this->lang; } int getOption() const { return this->option; } int getLast() const { if (this->choice == alpha) { return char('A' + this->totalItems); }
  • 46. else { return this->totalItems + 1; } } friend ostream & operator <<(ostream & os, Menu & unMenu) { int i; char ch = 'a'; cls(); os << unMenu.title << endl << endl; for (i = 0; i < unMenu.totalItems; i++) { os << "t"; if (unMenu.choice == alpha) os << char(ch + i); else os << i + 1; os << ".) " << unMenu.items[i] << endl; } os << "t"; if (unMenu.choice == alpha) os << char(ch + i); else os << i + 1; os << ".) "; if (unMenu.lang == eng) { if (unMenu.subMenu) os << "Return"; else os << "Exit"; os << " Choose: "; } else { if (unMenu.subMenu) os << "Regresar"; else os << "Salir"; os << " Opcion: "; } return os; } friend istream & operator >>(istream & in, Menu & unMenu) {
  • 47. do { char opt; in >> opt; unMenu.setOption((unMenu.choice == alpha ? opt : opt - '0')); if (!unMenu.check()) { cerr << " Error: Wrong choice!!! "; pause(); cout << unMenu; } } while (!unMenu.check()); return in; } }; #endif // MENU_H mylib.h #pragma once #include #include using namespace::std; #ifndef MYLIB_H #define MYLIB_H typedef bool flag; #ifdef WINDOWS #define cls() system("cls") #define pause() system("pause") #elif windows #define cls() system("cls") #define pause() system("pause") #elif LINUX #define cls() system("clear") #define pause() system("sleep 3") #elif linux #define cls() system("clear") #define pause() system("sleep 3") #else
  • 48. #define cls() { cerr << "CLS: Unknown OS!!! "; } #define pause() { cerr << "PAUSE: Unknown OS!!! "; } #endif #define between(x, y, z) ((x >= y && x <= z)? true : false) #define upper(x) (between(x, 'A', 'Z')? x : (between(x, 'a', 'z')? x - 'a' + 'A' : x)) #define lower(x) (between(x, 'a', 'z')? x : x - 'A' + 'a') #endif // MYLIB_H DataParser.h #include "DataParser.h" #include #include"Person.h" #include"Report.h" DataParser::DataParser() { record; } DataParser::DataParser(string line) { parseLine(line); } DataParser::DataParser(const DataParser & unDataParser) { this->record = unDataParser.record; this->fecha = unDataParser.fecha; } DataParser::~DataParser() { } Data DataParser::parseLine(string line) { Person client;//atributos de clase Person y Data string callDate; bool longDistance; string timeCallBegin; string timeCallEnd; string callNoFrom;
  • 49. string callNoTo; string firstName; string lastName; string middleName; string maidenName; //substr demostrara en que linea firstName = line.substr(0, 25); middleName = line.substr(25, 25); lastName = line.substr(50, 50); maidenName = line.substr(100, 50); callDate = line.substr(150, 8); if (line.substr(158, 1) == "Y")//yes or no longDistance = true; else longDistance = false; timeCallBegin = line.substr(159, 6); timeCallEnd = line.substr(165, 6); callNoFrom = line.substr(171, 10); callNoTo = line.substr(181, 10); record.setClient(Person(firstName, middleName, lastName, maidenName)); record.setCallDate(callDate); record.setLongDistance(longDistance); record.setTimeCallBegin(timeCallBegin); record.setTimeCallEnd(timeCallEnd); record.setCallNoFrom(callNoFrom); record.setCallNoTo(callNoTo); return record; } void DataParser::setRecord(string line) { parseLine(line); } Data DataParser::getRecord() const { return (this->record);
  • 50. } string DataParser::date(string date) { string fecha; fecha = date.substr(191, 2) + "/" + date.substr(193, 2) + "/" + date.substr(195, 4); return fecha; } void DataParser::setFecha(int fecha) { this->fecha = fecha; } int DataParser::getFecha()const { return(this->fecha); } DataParser.h #pragma once #include #include #include "Data.h" using namespace std; class DataParser { private: Data record; int fecha; public: DataParser(); DataParser(string line); DataParser(const DataParser & unDataPaser); ~DataParser(); void setRecord(string line); void setFecha(int fecha); int getFecha()const; Data getRecord()const; Data parseLine(string line);
  • 51. string date(string date); // friend ostream & operator <<(ostream & os, const DataParser & unDataParser); // friend istream & operator >> (istream & is, DataParser & unDataParser); }; Report.cpp #include "Report.h" Report::Report() { records = NULL; totalRecords = 0; totalMinutes = 0.0; totalAmmount = 0.0; fileName=(" "); } Report::Report(Data records, int totalRecords, float totalMinutes, float totalAmmount, string fileName) { setTotalRecords(totalRecords); setTotalMinutes(totalMinutes); setTotalAmmount(totalAmmount); setFileName(fileName); } void Report::addRecord(const Data & unData) { Data *records; records = new Data[this->totalRecords + 1]; for (int i = 0;i < this->totalRecords;i++) { records[this->totalRecords] = unData; delete[](this->records); this->records = records; ++(this->records); } } Report::Report(const Report & unReport)
  • 52. { this->records = NULL; totalRecords = unReport.totalRecords; totalMinutes = unReport.totalMinutes; totalAmmount = unReport.totalAmmount; fileName = unReport.fileName; (*this) = unReport; } Report::~Report() { delete[](this->records); } void Report::setTotalRecords(int totalRecords) { this->totalRecords = totalRecords; } void Report::setTotalAmmount(float totalAmmount) { this->totalAmmount = totalAmmount; } void Report::setTotalMinutes(float totalMinutes) { this->totalMinutes = totalMinutes; } void Report::setFileName(string fileName) { this->fileName = fileName; } const Data & Report::operator[](int indice)const { return((this->records)[indice]); } Data Report::getRecords()const { for (int i = 0;i < totalRecords;i++) {
  • 53. return (records[i]); } } int Report::getTotalRecords()const { return this->totalRecords; } float Report::getTotalAmmount()const { return this->totalAmmount; } float Report::getTotalMinutes()const { return this->totalMinutes; } string Report::getFileName()const { return this->fileName; } Report & Report::operator =(const Report & unReport) { delete[](this->records); if (unReport.totalRecords > 0) { this->records = new Data[unReport.totalRecords]; for (int i = 0;i < unReport.totalRecords;i++) { (this->records[i] = (unReport.records)[i]); } } else { this->records = NULL; } this->totalAmmount = unReport.totalAmmount; this->totalMinutes = unReport.totalMinutes;
  • 54. this->fileName = unReport.fileName; return (*this); } bool Report::operator ==(const Report & unReport)const { bool record = false; for (int i = 0;i < unReport.totalRecords;i++) { if (records[i] == unReport.records[i]) { record = true; } return record; } return (this->totalRecords == unReport.totalRecords && this->totalAmmount == unReport.totalAmmount && this->totalMinutes == unReport.totalMinutes && this->fileName == unReport.fileName); } ostream & operator <<(ostream & os, const Report & unReport) { for (int i = 0; i < unReport.totalRecords;i++) { os << "Record number is: " << unReport.records[i] << endl; } return os; } istream & operator >>(istream & is, Report & unReport) { cout << "Enter record:" << unReport.records << endl;; cout << "Total Records are: "; is >> unReport.totalRecords; cout << "Total Ammount: "; is >> unReport.totalAmmount; cout << "Total Minutes:"; is >> unReport.totalMinutes; cout << "File name is: ";
  • 55. is >> unReport.fileName; return is; } Report.h #pragma once #include"Data.h" #include #include using namespace std; class Report { private: Data *records; int totalRecords; float totalMinutes; float totalAmmount; string fileName; public: Report(); Report(Data records,int totalRecords, float totalMinutes, float totalAmmount, string fileName); Report(const Report & unReport); ~Report(); void addRecord(const Data & unData); void setTotalRecords(int totalRecords); void setTotalMinutes(float totalMinutes); void setTotalAmmount(float totalAmmount); void setFileName(string fileName); const Data & operator[](int indice)const; Data getRecords()const; int getTotalRecords()const; float getTotalMinutes()const; float getTotalAmmount()const; string getFileName()const; Report & operator = (const Report & unReport); bool operator ==(const Report & unReport)const;
  • 56. friend ostream & operator<<(ostream & os, const Report & unReport); friend istream & operator>>(istream & is, Report & unReport); };