C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 10th, 2012, 12:08 PM
MIMO-OFDM MIMO-OFDM is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 MIMO-OFDM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 47 sec
Reputation Power: 0
Question Need help to solve problems in object-oriented programming

Need help to solve questions in object-oriented programming
the questions are as follows:



Part1 . Implement the class Time defined as follows:
/* Time.h */
#ifndef TIME_H_
#define TIME_H_
class Time {
public:
Time(); // constructor
void setTime( int, int, int ); // set hour, minute, second
void printTime() const; // print time format h:m:s
private:
int hour; // 0 - 23 (24-hour clock format)
int minute; // 0 - 59
int second; // 0 - 59
};
#endif /* TIME_H_ */

The implementation of the class Time is as follows:
/* Time.cpp */
#include <iostream>
#include "Time.h"
using namespace std;
// Time constructor
Time::Time()
{
hour = 0;
minute = 0;
second = 0;
}
// set new Time value
void Time::setTime( int h, int m, int s )
{
hour = ( h >= 0 && h < 24 ) ? h : 0;
minute = ( m >= 0 && m < 60 ) ? m : 0;
second = ( s >= 0 && s < 60 ) ? s : 0;
}
// print Time
void Time::printTime() const
{
cout << hour << ":" << minute << ":" << second << "\n";
}
a. Add a new member function to the class Time that allows setting the time using AM and PM. The function should take four arguments: hour, minute, second, and AMPM. It should convert the input into a 24‐hour time system and set the data members hour, minute, second of the class Time, accordingly.
b. Add a new member function to the class Time that prints the time using AM PM. For example if the time is 23:10:30 then the function should return 11:10:30PM.
c. Test the new functions as follows:
a. ‐ Dynamically create two objects of class Time.
b. Invoke the new member functions on both objects so as to validate their correctness.


d. Add a new function to the class Date that sets the date. The function should take three arguments that represents the day, month, and year and sets the data members of the class Date. Ensure that the dates are valid. For example, you should not have a day which is beyond 31. Assume that we do not deal with leap years (a year with an extra day).
e. Add a new function to the class Date that returns the month in letters (e.g., January, February, etc.).
f. Add a new function that returns the number of days between two given dates. d. Test the new functions of the class Date by:
a. Dynamically create two objects of class Date.
b. Invoke the new member functions on both objects so as to validate their correctness.
c.
Part2. Create a class called Passenger that represents passengers of an airline company. A passenger is defined by the following information:
‐ Passenger ID (int)
‐ Name (string)
‐ Address (string)
‐ Tel (string)
‐ Date of birth (of type Date from Q2)
Provide the following functions:
‐ A constructor that initializes the data members and provides default arguments.
‐ Accessor methods that return the value of the data members.
‐ Functions that change the address, tel., and date of birth of a passenger.
‐ A function that prints information about a passenger.
Test your class by dynamically creating two Passenger objects and calling on them the above functions.

Part3. Create a class Flight that represents information about a particular flight. A flight is defined by a flight number (string), departure and arrival dates (type Date from Q2), departure and arrival times (type Time from part1), the arrival city (string), and the list of passengers on this flight (an array whose elements are of type Passenger from Part2). For the creation of the array, you may assume that all flights have the same capacity.
The class Flight should have the following member functions:
‐ A constructor that sets the flight number, departure date and time, arrival date and time.
‐ A function that returns the duration of the flight in hours.
‐ A function that adds a passenger to the list of passengers. Recall that a passenger is of type Passenger.
‐ A function that removes a passenger from the list of passengers. The function takes passenger ID as input.
‐ A function that returns true if a given person is on the passenger’s list, false otherwise.
‐ A function that prints the list of passengers.
‐ A function that returns the number of seats available.

Test your class by creating two objects of the class Flight. For each class, you should create at least 5 passengers. All objects must be created dynamically.
In this question, we encourage you to use the program analysis steps explained in the class, and which consist of identifying and formulating the problem, thinking of which variables you should use, analyzing the problem and the various possible solutions, and solving it. Similarly to parts 1‐3, you only need to submit the final program code. You do not have to document the problem analysis steps.

Reply With Quote
  #2  
Old November 10th, 2012, 01:11 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,125 dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 16 h 49 m 34 sec
Reputation Power: 1949
OK, so what have you done so far?

And do you have any questions? I didn't see any questions there, nothing but a verbatim copy of your assignment problems. Almost as if you want us to do your work for you, which would be aiding you to commit plagiarism, an academic crime that would get you expelled. Certainly you wouldn't want that, so that leaves us right where we started, wondering what your question is.

Reply With Quote
  #3  
Old November 10th, 2012, 01:16 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,353 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 8 h 3 m 36 sec
Reputation Power: 383
By God if you can solve this Pan Am will hire you in a flash! (Is Pan Am still operating?) Seriously, if you write some code, and it doesn't work, and you can't figure out why, and you compiled with all warnings turned on, and you post it here you'll about certainly get good help.
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Need help to solve problems in object-oriented programming

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap