1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
while(!ffile.eof())
{
getline(ffile, line);
copy = line;
ss.str(line);
ss >> type;
if (type == "Residential")
{
ss >> rent_or_own >> price >> occupation;
getline(ss, address);
if (ss.fail() || price < 0)
{
cout << "Error, ignoring bad input: " << copy << endl << endl;
ss.clear();
ss.ignore(1000, '/n');
}
else
{
Residential* r = new Residential (rent_or_own, price, occupation, address);
properties.push_back(r);
}
}
else if (type == "Commercial")
{
ss >> rent_or_own >> price >> tax_eligibility >> tax_discount;
getline(ss, address);
if (ss.fail() || price < 0)
{
cout << "Error, ignoring bad input: " << copy << endl << endl;
ss.clear();
ss.ignore(1000, '/n');
}
else
{
Commercial* c = new Commercial(rent_or_own, price, tax_discount, tax_eligibility, address);
properties.push_back(c);
}
}
else
{
cout << "Error, ignoring bad input: " << copy << endl << endl;
}
}
| |