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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;
class Subscriber{
private:
int subscriberNumber;
string lastName;
string firstName;
string streetAddress;
string city;
string state;
int zipcode;
int expirationdate;
public:
Subscriber() : subscriberNumber(0), zipcode(0), expirationdate(0) { }
Subscriber(int number, string last, string first, string address,
string cty, string st, int zip, int expdate) :
subscriberNumber(number), lastName(last), firstName(first),
streetAddress(address), city(cty), state(st), zipcode(zip),
expirationdate(expdate) { }
void print() const;
};
class SubscriberHandling {
private :
int sub_id;
int curDate;
vector<Subscriber> subscribers;
public:
SubscriberHandling(int date);
void hardCode();
void printAll();
void addSubscriber();
void expiredSubscriptions();
void unexpiredSubscriptions();
void subscriptionsInState(string state);
void subscriptionExpiringInTwoMonths();
void searchSubscriber(int num);
};
//driver function
int main()
{
SubscriberHandling sh(2001);//set current date as 2001
sh.printAll();
sh.expiredSubscriptions();
SubscriberHandling sh1(1712);
sh1.unexpiredSubscriptions();
sh.searchSubscriber(105);
cin.get();//to hold the console screen
return 0;
}
void Subscriber::print() const
{
cout << left << setw(19) << "Id:" << subscriberNumber
<< setw(20) << "\nFirst name: " << firstName
<< setw(20) << "\nLast name: " << lastName
<< setw(20) << "\nStreet Address: " << streetAddress
<< setw(20) << "\nCity: " << city
<< setw(20) << "\nState: " << state
<< setw(20) << "\nZip-code: " << zipcode
<< setw(20) << "\nExpiration date: " << expirationdate
<< "\n\n" << right;
}
//parameterised constructor
SubscriberHandling::SubscriberHandling(int date)
{
curDate=date;//set current date
sub_id=101;//initial value of subscriber
hardCode();
}
// hardcode method
void SubscriberHandling:: hardCode()
{
// add the subscribers into the list
subscribers.push_back( Subscriber(101, "Gray", "John", "233 Parkview Road", "Flushing", "Michigan", 47489, 1809) );
subscribers.push_back( Subscriber(102, "Tang", "Charlotte", "303 E. Kearsley Street", "Flint", "Michigan", 48502, 1712) );
subscribers.push_back( Subscriber(103, "Brown", "Coral", "8890 Holly Road", "Grand Blanc", "Michigan", 48439, 1709) );
subscribers.push_back( Subscriber(104, "Arai", "Hugh", "77 Riverside Walk", "San Antonio", "Texas", 25786, 1805) );
subscribers.push_back( Subscriber(105, "Blackett", "Kevin", "125 Picking Circle", "San Jose", "California", 60089, 1704) );
subscribers.push_back( Subscriber(106, "Achtemichuk", "Mark", "3987 143 St", "Flint", "Michigan", 48503, 1810) );
subscribers.push_back( Subscriber(107, "Browning", "William", "1 Down Street", "Washington", "D.C.", 24675, 1712) );
subscribers.push_back( Subscriber(108, "Brown", "Maureen", "9066 Osoyoo Crescent", "New York City", "New York", 10021, 1802) );
}
//add subscriber function
void SubscriberHandling::addSubscriber()
{
}
//expired subscriptions
void SubscriberHandling::expiredSubscriptions()
{
}
//subscriptionsexpiring in 2 months
void SubscriberHandling::subscriptionExpiringInTwoMonths()
{
}
//search for a subscriber using id
void SubscriberHandling::searchSubscriber(int num)
{
}
//subscriptions in a state
void SubscriberHandling::subscriptionsInState(string state)
{
}
//display subscriptions unexpired
void SubscriberHandling::unexpiredSubscriptions()
{
}
// Print All Subsribers
void SubscriberHandling::printAll()
{
for (const auto & s : subscribers)
s.print();
}
|