Advertisement
Guest User

Sleepless Nights

a guest
Sep 21st, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.00 KB | None | 0 0
  1. //
  2. //  main.cpp
  3. //  sleeplessNights
  4. //
  5. //  Created by Samar Sunkaria on 9/22/14.
  6. //  Copyright (c) 2014 Samar Sunkaria. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. using namespace std;
  11.  
  12. class Victim {
  13.    
  14.     int noOfNights;
  15.     string name;
  16.    
  17.     public :
  18.    
  19.     Victim () {
  20.        
  21.         noOfNights = 0;
  22.         name = "Untitled";
  23.     }
  24.    
  25.     void addVictim() {
  26.        
  27.         cout << "Please Enter your name : ";
  28.         cin >> name;
  29.        
  30.         cout << "Enter the number of sleepless nights : ";
  31.         cin >> noOfNights;
  32.        
  33.     }
  34.    
  35.     void showVictim() {
  36.        
  37.         cout << "Name                       : " << name << endl;
  38.         cout << "Number of sleepless nights : " << noOfNights << endl;
  39.        
  40.     }
  41.    
  42.     void addNight() {
  43.        
  44.         noOfNights++;
  45.        
  46.     }
  47.    
  48. };
  49.  
  50. int main(int argc, const char * argv[]) {
  51.    
  52.     Victim vic[45];
  53.     int truth = 0;
  54.     int i = 0;
  55.    
  56.     int option;
  57.  
  58.     do {
  59.  
  60.     cout << "Enter one of the following options" << endl;
  61.     cout << "1. Add Victim" << endl;
  62.     cout << "2. Display Profile" << endl;
  63.     cout << "3. Add a night" << endl;
  64.     cout << "0. Exit" << endl;;
  65.    
  66.     cin >> option;
  67.    
  68.     switch (option) {
  69.    
  70.     case 1:
  71.    
  72.         while (truth == 0) {
  73.            
  74.             vic[i].addVictim();
  75.             cout << "Your account number is : " << i + 1 << endl;
  76.        
  77.             i++;
  78.        
  79.             cout << "Do you want to add anothet victim? (Y/N) : ";
  80.             char ans;
  81.             cin >> ans;
  82.             truth = ((ans == 'Y') ? 0 : 1);
  83.            
  84.         }
  85.    
  86.         break;
  87.    
  88.     case 2:
  89.            
  90.         while (truth == 0) {
  91.            
  92.             int accNo;
  93.             cout << "Enter for account number : ";
  94.             cin >> accNo;
  95.            
  96.             cout << endl;
  97.             cout << "Account Number             : " << accNo << endl;
  98.             vic[accNo].showVictim();
  99.            
  100.             cout << "Do you want to access another profile? (Y/N) : ";
  101.             char ans;
  102.             cin >> ans;
  103.             truth = ((ans == 'Y') ? 0 : 1);
  104.    
  105.         }
  106.            
  107.         break;
  108.    
  109.     case 3:
  110.        
  111.         while (truth == 0) {
  112.            
  113.             int accNo;
  114.             cout << "Enter for account number : ";
  115.             cin >> accNo;
  116.            
  117.             vic[accNo].addNight();
  118.            
  119.             cout << endl;
  120.             cout << "Account Number             : " << accNo << endl;
  121.             vic[accNo].showVictim();
  122.            
  123.             cout << "Do you want to add a night to another account (Y/N) : ";
  124.             char ans;
  125.             cin >> ans;
  126.             truth = ((ans == 'Y') ? 0 : 1);
  127.            
  128.         }
  129.     }
  130.         truth = 0;
  131.        
  132.         cout << "Do you want to continue? (Y/N) : ";
  133.         char ans;
  134.         cin >> ans;
  135.         option = ((ans == 'Y') ? 0 : 1);
  136.    
  137.     }
  138.    
  139.     while (option == 0);
  140.    
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement