Polymorphic TVs
Solution 1:
Question 2:
Solution 2:
#include
#include
using namespace std;
#define MOD 1000000007
#define ll long long
#define slld(t) scanf(“%lld”,&t)
#define sd(t) scanf(“%d”,&t)
#define sld(t) scanf(“%ld”,&t)
#define pd(t) printf(“%d\n”,t)
#define plld(t) printf(“%lld\n”,t)
#define pcc pair
#define pp pair
#define pll pair
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define pb(x) push_back(x)
class Rental
{
private:
stringshopId; //s1, s2, s3 ….. s10
stringmallId; //m1, m2, m3
int month;
double amount;
public:
Rental(string=” “, string=” “, int = 0, double= 0);
voidsetRental(string x, string y, int a, double b)
{
shopId=x;
mallId=y;
month=a;
amount = b;
}
stringgetShopId()
{
returnshopId;
}
stringgetMallID()
{
returnmallId;
}
intgetMonth()
{
return month;
}
doublegetAmount()
{
return amount;
}
};
class Consolidation
{
private:
Rental r[50];
intrcount=0;
public:
voidreadFile()
{
// take file input here
// use this method
fstreamdatafile;
datafile.open(“your file name”);
while(!datafile.empty())
{
// take inputs here
datafile>>value;
rcount += value;
// r count is rent for that month
}
}
voidwriteFile(int month)
{
// this will write file to the output location
fstreamdatafile;
datafile.open(“output file name”);
while(!datafile.empty())
{
// write output here
datafile<<“variables”<
datafile<
}
}
};
int main()
{
Consolidation s;
s.readFile();
s.writeFile();
}