And Once Again I return with a very drastic Problem...
this is regarding the the program i should make. I have come across something in my exe file stating that "Insurance File Removed" even though i have nothing printing that on the screen and after it displays that it closes the exe. the coding i have so far are these.:
Code:
#include<iostream>
#include<string>
using std:: string;
using namespace std;
#include"Date.h"
#include"Client.h"
#include"Home.h"
#include"Home_Insurance.h"
#include"Insurance.h"
#include"Life_Insurance.h"
#include"MotorVehicle_Insurance.h"
#include"Vehicle.h"
#include<conio.h>
#include<fstream>
void main (void)
{
int opt;
HomeIns home;
ofstream PolicyFile ("Policy.txt");
//cout<<"\t\t\tAdd\n\n\t\t\tView\n\n\t\t\tEdit\n\n\t\t\tDelete";
//system("CLS");
home.AddHome();
getch();
}
This is the main taking a function call. o i havent implemented the file yet so ignore that please.
Code:
#ifndef HOME_H
#define HOME_H
#include "Client.h"
class Home{
private:
// :Client: Client
float house_val;
string FLaddr;
string SLaddr;
string roof_type;
//bool fire_alarm;
//bool burg_alarm;
public:
Home();
Home(float, string, string, string);
~Home();
void setHouseVal(float);
void setFAddress(string);
void setSAddress (string);
void setRoofType(string);
float getHouseVal();
string getFAddress();
string getSAddress();
string getRoofType();
bool Fire_Alarm(void);
bool Burg_Alarm(void);
};
#endif
Header for Home
Code:
#ifndef HOME_INSURANCE_H
#define HOME_INSURANCE_H
#include "Insurance.h"
#include "Home.h"
using std::string;
using namespace std;
class HomeIns: public Policy {
private:
Home home;
int home_count;
float premi;
public:
HomeIns();
HomeIns(Home&, float);
~HomeIns();
HomeIns AddHome(void);
void DeleteHome(HomeIns&);
Home EditHome(Home&);
void ViewHome(Home&);
void setHomeData(Home&);
Home getHomeData();
//void setHome(Home&);
//Home getHome();
float Premium (float);
};
#endif
home insurance header
Code:
#include<iostream>
#include"Home.h"
using std::string;
using namespace std;
#include<string>
Home:: Home(){
}
Home:: Home(float val, string fAddy, string sAddy, string R_type){
setHouseVal(val);
setFAddress(fAddy);
setSAddress (sAddy);
setRoofType(R_type);
}
Home:: ~Home(){
}
void Home:: setHouseVal(float est_val){
house_val= est_val;
}
void Home:: setFAddress(string addyone){
FLaddr= addyone;
}
void Home:: setSAddress (string addytwo){
SLaddr= addytwo;
}
void Home:: setRoofType(string roof){
roof_type= roof;
}
float Home:: getHouseVal(){
return house_val;
}
string Home:: getFAddress(){
return FLaddr;
}
string Home:: getSAddress(){
return SLaddr;
}
string Home:: getRoofType(){
return roof_type;
}
bool Home:: Fire_Alarm(void){
string alarm;
cout<<"\nDoes the Home Have A Fire Alarm?"<<"\nYes\t\tNo:\n";
cin>> alarm;
system("CLS");
if (alarm== "yes" || alarm== "Yes"){
return true;
}
else
return 0;
}
bool Home:: Burg_Alarm(void){
string alarm;
cout<<"\nDoes the Home Have A Burglar Alarm?"<<"\nYes\t\tNo:\n";
cin>> alarm;
system("CLS");
if (alarm== "yes" || alarm== "Yes"){
return true;
}
else
return 0;
}
Implimentation for Home
Code:
#include<iostream>
#include"Home.h"
using std::string;
using namespace std;
#include<string>
#include "Home_Insurance.h"
#include<dos.h>
#include<time.h>
#include<windows.h>
#include"Insurance.h"
HomeIns:: HomeIns()
{
}
HomeIns:: ~HomeIns(){
}
HomeIns:: HomeIns(Home &mhome, float prem){
home=mhome;
premi= prem;
}
HomeIns HomeIns:: AddHome(void)
{
HomeIns *nHome;
float home_val;
string fladdr;
string sladdr;
string Roof_Type;
float premium_cost;
cout<<"Please Enter The Value Of The House: ";
cin>>home_val;
cout<<"\n\nPlease Enter The First Line Of Address For The House: ";
cin>>fladdr;
cout<<"\n\nPlease Enter The Second Line Of Address For The House: ";
cin>>sladdr;
cout<<"\n\n\Please Enter The Roof Type of The House: ";
cin>>Roof_Type;
system("CLS");
Home home(home_val, fladdr, sladdr, Roof_Type);
premium_cost= Premium(home_val);
nHome= new HomeIns(home, premium_cost);
return *nHome;
}
float HomeIns:: Premium (float hval){
float final_premium;
bool f_alarm;
bool b_alarm;
f_alarm= home.Fire_Alarm();
b_alarm= home.Burg_Alarm();
if (f_alarm== 1 && b_alarm==1){
final_premium= hval * (2/100);
final_premium= final_premium-(hval*(1/100));
if (f_alarm==1 && b_alarm== 0 || f_alarm==0 && b_alarm== 1){
final_premium= hval * (2/100);
final_premium= final_premium-(hval*(0.5/100));
}
}
else {
final_premium= hval * (2/100);
}
return final_premium;
}
void HomeIns:: DeleteHome(HomeIns &mhome){
HomeIns *qhome;
qhome=&mhome;
delete qhome;
}
Home HomeIns:: EditHome(Home &mhome){
HomeIns house;
float home_val;
string fLaddr;
string sLaddr;
string Roof_Type;
int opt, opt2;
cout<<"\t\t\t\tWhat Information On the Home Would You Like to Edit: \n\n\t\t\t1.The Value Of The Home.\n\n\t\t\t2.The First Line Address Of The Home.\n\n\t\t\t3. The Second Line Address of The Home.\n\n\t\t\t4.The Roof Type Of The Home.";
cin>>opt;
switch (opt){
case 1:
cout<<"\n\n\t\t\tEnter The New Value Of The Home: ";
cin>>home_val;
mhome.setHouseVal(home_val);
cout<<"\n\n\t\tDo You Want To Edit Any Thing Else?\n\n\t\t1.Yes\n\n\t\t2.No";
cin>>opt2;
switch (opt2){
case 1:
EditHome(mhome);
break;
case 2:
return mhome;
break;
default:
return mhome;
}
break;
case 2:
cout<<"\n\n\t\t\tEnter The New First Line Of Address Of The Home: ";
cin>>fLaddr;
mhome.setFAddress(fLaddr);
cout<<"\n\n\t\tDo You Want To Edit Any Thing Else?\n\n\t\t1.Yes\n\n\t\t2.No";
cin>>opt2;
switch (opt2){
case 1:
EditHome(mhome);
break;
case 2:
return mhome;
break;
default:
return mhome;
}
break;
case 3:
cout<<"\n\n\t\t\tEnter The New Second Line Of Address Of The Home: ";
cin>>sLaddr;
mhome.setSAddress(sLaddr);
cout<<"\n\n\t\tDo You Want To Edit Any Thing Else?\n\n\t\t1.Yes\n\n\t\t2.No";
cin>>opt2;
switch (opt2){
case 1:
EditHome(mhome);
break;
case 2:
return mhome;
break;
default:
return mhome;
}
break;
case 4:
cout<<"\n\n\t\t\tEnter The New Roof Type: ";
cin>>Roof_Type;
mhome.setRoofType(Roof_Type);
cout<<"\n\n\t\tDo You Want To Edit Any Thing Else?\n\n\t\t1.Yes\n\n\t\t2.No";
cin>>opt2;
switch (opt2){
case 1:
EditHome(mhome);
break;
case 2:
return mhome;
break;
default:
return mhome;
}
break;
default:
EditHome(mhome);
}
return mhome;
}
void HomeIns:: ViewHome(Home &mhome){
string answer;
cout<<"\n\n\t\tThis Is The House Value: "<<mhome.getHouseVal();
Sleep(2);
cout<<"\n\n\t\tThis Is The First Line Of Address Of The House: "<<mhome.getFAddress();
Sleep(2);
cout<<"\n\n\t\tThis Is The Second Line Of Address Of The House: "<<mhome.getSAddress();
Sleep(2);
cout<<"\n\n\t\tThis Is The Roof Type Of The House The House: "<<mhome.getRoofType();
Sleep(2);
cout<<"\n\n\t\tDoes The House Have a Burglar Alarm: ";
mhome.Fire_Alarm();
if (mhome.Fire_Alarm()==1){
answer="yes";
}
cout<<answer;
Sleep(2);
}
implimentation for hom insurance and thats about it i dont kno what cout be causing ma problem to be showing "Insurance File Removed" after it calls the two alarm functions and accepts input from the user. Please help as am lost with this one.