Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // sleeplessNights
- //
- // Created by Samar Sunkaria on 9/22/14.
- // Copyright (c) 2014 Samar Sunkaria. All rights reserved.
- //
- #include <iostream>
- using namespace std;
- class Victim {
- int noOfNights;
- string name;
- public :
- Victim () {
- noOfNights = 0;
- name = "Untitled";
- }
- void addVictim() {
- cout << "Please Enter your name : ";
- cin >> name;
- cout << "Enter the number of sleepless nights : ";
- cin >> noOfNights;
- }
- void showVictim() {
- cout << "Name : " << name << endl;
- cout << "Number of sleepless nights : " << noOfNights << endl;
- }
- void addNight() {
- noOfNights++;
- }
- };
- int main(int argc, const char * argv[]) {
- Victim vic[45];
- int truth = 0;
- int i = 0;
- int option;
- do {
- cout << "Enter one of the following options" << endl;
- cout << "1. Add Victim" << endl;
- cout << "2. Display Profile" << endl;
- cout << "3. Add a night" << endl;
- cout << "0. Exit" << endl;;
- cin >> option;
- switch (option) {
- case 1:
- while (truth == 0) {
- vic[i].addVictim();
- cout << "Your account number is : " << i + 1 << endl;
- i++;
- cout << "Do you want to add anothet victim? (Y/N) : ";
- char ans;
- cin >> ans;
- truth = ((ans == 'Y') ? 0 : 1);
- }
- break;
- case 2:
- while (truth == 0) {
- int accNo;
- cout << "Enter for account number : ";
- cin >> accNo;
- cout << endl;
- cout << "Account Number : " << accNo << endl;
- vic[accNo].showVictim();
- cout << "Do you want to access another profile? (Y/N) : ";
- char ans;
- cin >> ans;
- truth = ((ans == 'Y') ? 0 : 1);
- }
- break;
- case 3:
- while (truth == 0) {
- int accNo;
- cout << "Enter for account number : ";
- cin >> accNo;
- vic[accNo].addNight();
- cout << endl;
- cout << "Account Number : " << accNo << endl;
- vic[accNo].showVictim();
- cout << "Do you want to add a night to another account (Y/N) : ";
- char ans;
- cin >> ans;
- truth = ((ans == 'Y') ? 0 : 1);
- }
- }
- truth = 0;
- cout << "Do you want to continue? (Y/N) : ";
- char ans;
- cin >> ans;
- option = ((ans == 'Y') ? 0 : 1);
- }
- while (option == 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement