use vc++ to complete, Description measurement.cpp -Write all of the member functions for the class m 1 answer below »

use vc++ to complete,

Description

measurement.cpp  

-Write all of the member functions for the class measurement.

– Use the starter file measurement.cpp

– The driver is already written.

– Execute the program and check that your answers are correct.

NOTE: Study the sample programs timeOfDay.cpp and dayOfYear in the sample

              programs folder A????1 Classes for ideas in completing measurement.cpp

measurement.cpp #include <iostream> using namespace::std; class measurement { public: // Constructors measurement(void); measurement(int y, int f, int i); // Mutator Functions void setYards(int); void setFeet(int); void setInches(int); // Accessor Functions int getYards(void); int getFeet(void); int getInches(void); // Other Functions void advanceOneInch(); // increase the inches amount by 1 // NOTE: you may have to advance the feet // you may have to advance the yards void output(ostream &); void zeroOut(void); // set yards, feet and inches to 0 private: int yards; int feet; int inches; }; void main() { measurement stackOfLumber(3,2,5); for( int i = 1; i <= 200; i++) { stackOfLumber.advanceOneInch(); stackOfLumber.output(cout); } stackOfLumber.zeroOut(); stackOfLumber.output(cout); stackOfLumber.setYards(6); stackOfLumber.setFeet(2); stackOfLumber.setInches(3); cout << stackOfLumber.getYards() << ‘ ‘ << stackOfLumber.getFeet() << ‘ ‘ << stackOfLumber.getInches() << endl; return; } // WRITE THE measurement FUNCTIONS BELOW

dayOfYear.cpp #include <iostream> using namespace std; class DayOfYear { public: void input( ); void output( ); void set(int new_month, int new_day); //Precondition: new_month and new_day form a possible date. //Postcondition: The date is reset according to the arguments. int get_month( ); //Returns the month, 1 for January, 2 for February, etc. int get_day( ); //Returns the day of the month. bool isNewYearsDay( ); int getTheNextMonth(); bool isTheDay( int dayToCheck ); private: void check_date( ); int month; int day; }; bool endOfMonth( DayOfYear & ); int main( ) { DayOfYear today2; today2.input(); today2.output(); // use ouput function to display the data in the object DayOfYear nextClass; nextClass.set(10,10); cout << “Next class is month ” << nextClass.get_month() << ” and day is ” << nextClass.get_day() << endl; if ( endOfMonth(today2) == true ) cout << “today is end of month” << endl; else cout << “Not end of month” << endl; if ( today2.isNewYearsDay() == true ) cout << “today is New Years ” << endl; else cout << “today is not New Years” << endl; cout << “the next month from today is ” << today2.getTheNextMonth() << endl; if ( today2.isTheDay(1) == true ) cout << “Pay the rent today” << endl; else cout << “Worry about the rent some other day” << endl; DayOfYear today, bach_birthday; cout << “Enter today’s date:n”; today.input( ); cout << “Today’s date is “; today.output( ); bach_birthday.set(3, 21); cout << “J. S. Bach’s birthday is “; bach_birthday.output( ); if ( today.get_month( ) == bach_birthday.get_month( ) && today.get_day( ) == bach_birthday.get_day( ) ) cout << “Happy Birthday Johann Sebastian!n”; else cout << “Happy Unbirthday Johann Sebastian!n”; return 0; } //Uses iostream: void DayOfYear::input( ) { cout << “Enter the month as a number: “; std::cin >> month; cout << “Enter the day of the month: “; cin >> day; check_date( ); } void DayOfYear::output( ) { cout << “month = ” << month << “, day = ” << day << endl; } void DayOfYear::set(int new_month, int new_day) { month = new_month; day = new_day; check_date(); } void DayOfYear::check_date( ) { if ((month < 1) || (month > 12) || (day < 1) || (day > 31)) { cout << “Illegal date. Aborting program.n”; exit(1); } } int DayOfYear::get_month( ) { return month; } int DayOfYear::get_day( ) { return day; } bool DayOfYear::isNewYearsDay() { if ( month == 1 && day == 1 ) return true; else return false; } int DayOfYear::getTheNextMonth() { int nextMonth; if ( month < 12) nextMonth = month + 1; else nextMonth = 1; return nextMonth; } bool DayOfYear::isTheDay( int dayToCheck ) { if ( dayToCheck == day ) return true; else return false; } bool endOfMonth( DayOfYear & t ) { int m, d; m = t.get_month(); d = t.get_day(); if ( d == 28 && m == 2 ) return true; else if ( d == 30 && ( m == 9 || m == 4 || m == 6 || m == 11 ) ) return true; else if ( d == 31 && ( m == 1 || m == 3 || m == 5 ||m == 7 || m == 8 || m == 10 || m == 12 ) ) return true; else return false; }

timeOfDay.cpp #include <iostream> #include <fstream> using namespace::std; class timeOfDay { public: // Constructors timeOfDay(void); timeOfDay(int h, int m); // Mutator Functions void setHours(int); void setMinutes(int); // Accessor Functions int getHours(void); int getMinutes(void); // Other Functions void advanceOneMinute(); void output(ostream &); void setToStartOfDay(void); // hours becomes 12 minutes becomes 0 private: int hours; int minutes; }; void main() { timeOfDay currentTime(4,36); // change the hours to 5 currentTime.setHours(5); cout << “The value of hours is now ” << currentTime.getHours() << endl; // advance the time 8 hours, I do not know the current hours currentTime.setHours( 8 + currentTime.getHours() ); cout << “The value of hours is now ” << currentTime.getHours() << endl; cout << “The current time is “; currentTime.output(cout); ofstream timeLog(“c:\temp\time.txt”); currentTime.output(timeLog); for( int i = 1; i <= 2000; i++) { currentTime.advanceOneMinute(); currentTime.output(cout); } return; } timeOfDay::timeOfDay(void) { // programmer picks default values hours = 12; minutes = 0; } timeOfDay::timeOfDay(int h, int m) { hours = h; minutes = m; } // Mutator Functions void timeOfDay::setHours(int h) { hours = h; } void timeOfDay::setMinutes(int m) { minutes = m; } // Accessor Functions int timeOfDay::getHours(void) { return hours; } int timeOfDay::getMinutes(void) { return minutes; } // Other Functions void timeOfDay::advanceOneMinute() { minutes++; if ( minutes == 60 ) { minutes = 0; hours++; if ( hours == 13 ) { hours = 1; } } } void timeOfDay::output(ostream & outS) { outS << hours << ‘:’ << minutes << endl; } void timeOfDay::setToStartOfDay(void) { hours = 12; minutes = 0; }

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer