/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <iostream>
#include <fstream>
using namespace std;
/*---------------------------------------------------*/
class Customer{
protected:
string name;
public:
Customer(string name = "Unknown"){
this->name = name;
}
string getName(){
return name;
}
void setName(string name = "Unknown"){
this->name = name;
}
};
/*---------------------------------------------------*/
class TV{
private:
int no;
public:
float price;
TV(){
cout << "The TV Number is : " << endl;
cin >> no;
cout << "The TV Price is : " << endl;
cin >> price;
}
float getPrice(){
return price;
}
int getNo(){
return no;
}
void setPrice(float p){
price = p;
}
};
/*---------------------------------------------------*/
class Invoice : protected Customer{
private:
float Total = 0;
public:
TV TVs[2];
void ReadPrice(){
for(int i=0;i<2;i++){
cout << "TVs[" << i << "] = (Number = " << TVs[i].getNo() << ", Price = " << TVs[i].getPrice() << ")" << endl;
}
};
int getTotal(){
return Total;
}
Invoice(string name) : Customer(name){
for(int i=0;i<2;i++){
Total += TVs[i].price;
}
}
void Print(){
cout << "The Name is : " << name << endl;
cout << "Total is : " << Total << endl;
cout << "TVs: " << endl;
this->ReadPrice();
}
void Print(string file) {
ofstream f;
f.open (file);
f << "The Name is : " << name << endl;
f << "Total is : " << Total << endl;
f << "TVs: " << endl;
for(int i=0;i<2;i++){
f << "TVs[" << i << "] = (Number = " << TVs[i].getNo() << ", Price = " << TVs[i].getPrice() << ")" << endl;
}
f.close();
}
int getMin(){
float min;
min = TVs[0].price;
for(int i=0 ;i < 2; i++){
if (TVs[i].price < min)
min = TVs[i].price;
}
cout<<"The minimum :" << min <<endl;
return min;
}
};
/*---------------------------------------------------*/
int main() {
Invoice* x[2];
//customer y;
for(int i=0; i<2;i++){
x[i] = new Invoice("Invoice " + to_string(i));
string filename = "output" + to_string(i) + ".txt";
x[i]->Print(filename);
x[i]->getMin();
cout<<"********************************"<<endl;
}
return 0;
}