C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 30th, 2005, 05:08 PM
mik8310 mik8310 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 1 mik8310 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 50 sec
Reputation Power: 0
Exclamation C++ Emer. Help!!!

Hi ya'll, thanks to whoever responds to this post, i'm in dire
need of some help on this C++ program.

Hate to ask for this much help, but seems like experts can make up these classes and functions better and quicker than i could.

The .doc file contains the startup code, PLS PLS someone help me get the func definitions and declarations!!!


We want to be able to work with objects that are of type Distance. A Distance can be thought of as consisting of two values: an integer number of feet and a double number of inches. The number of feet in a Distance object needs to be non-negative and the number of inches needs to be non-negative as well as strictly less than 12. When a Distance object is created (using a constructor), the values of feet and inches are specified (as two values, an int and a double); if both values are omitted, the Distance should default to 0 feet and 0 inches; if the only the second value is omitted, a default value of 0 inches should be used for that missing value. If the Distance is specified improperly (i.e., if either the feet or inches is out of range), the values should be automatically adjusted to legal values as follows: if the value for feet is negative, use the value 0 instead; if the value for the inches is either negative or is greater than or equal to 12, use the value 0 instead.

There should be a boolean member function, change, that will allow you to adjust the value of an existing Distance. The member function change should have two parameters, an int and a double. If the second parameter is omitted, a default value of zero should be used. If either of the parameters provided to change is out of range, ignore the request and return a value of false; otherwise, make the requested change and return true. There should also be an integer member function, rounded, that returns the number of feet in the given Distance (rounded to the nearest foot … 6 inches or more, go up).

There should be a void member function, add, that has one parameter of type Distance. The value of that parameter should be added to the calling object. There should be a boolean member function, times, that has one double parameter. If the value of that parameter is negative, ignore the request and return a value of false; otherwise, multiply the Distance by that parameter and return the value true. Finally, there should be a voidprint member function that will display the Distance (no C/R or spacing before or afterwards) using the format:

Reply With Quote
  #2  
Old March 31st, 2005, 12:59 AM
Cirus Cirus is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 276 Cirus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 11 h 48 m 58 sec
Reputation Power: 4
Are you refering to Robert Lafore??

Reply With Quote
  #3  
Old March 31st, 2005, 01:11 AM
Cirus Cirus is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 276 Cirus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 11 h 48 m 58 sec
Reputation Power: 4
Quote:
Originally Posted by mik8310
Hi ya'll, thanks to whoever responds to this post, i'm in dire
need of some help on this C++ program.

Hate to ask for this much help, but seems like experts can make up these classes and functions better and quicker than i could.

The .doc file contains the startup code, PLS PLS someone help me get the func definitions and declarations!!!


We want to be able to work with objects that are of type Distance. A Distance can be thought of as consisting of two values: an integer number of feet and a double number of inches. The number of feet in a Distance object needs to be non-negative and the number of inches needs to be non-negative as well as strictly less than 12. When a Distance object is created (using a constructor), the values of feet and inches are specified (as two values, an int and a double); if both values are omitted, the Distance should default to 0 feet and 0 inches; if the only the second value is omitted, a default value of 0 inches should be used for that missing value. If the Distance is specified improperly (i.e., if either the feet or inches is out of range), the values should be automatically adjusted to legal values as follows: if the value for feet is negative, use the value 0 instead; if the value for the inches is either negative or is greater than or equal to 12, use the value 0 instead.

There should be a boolean member function, change, that will allow you to adjust the value of an existing Distance. The member function change should have two parameters, an int and a double. If the second parameter is omitted, a default value of zero should be used. If either of the parameters provided to change is out of range, ignore the request and return a value of false; otherwise, make the requested change and return true. There should also be an integer member function, rounded, that returns the number of feet in the given Distance (rounded to the nearest foot … 6 inches or more, go up).

There should be a void member function, add, that has one parameter of type Distance. The value of that parameter should be added to the calling object. There should be a boolean member function, times, that has one double parameter. If the value of that parameter is negative, ignore the request and return a value of false; otherwise, multiply the Distance by that parameter and return the value true. Finally, there should be a voidprint member function that will display the Distance (no C/R or spacing before or afterwards) using the format:


For addition and times operation, you need to overload '+' and '*' operators with Distance as return object and parameter as Distance:

Code:
 Distance operator + ( Distance d1)
 { 
 
    Distance d; 
    d.feet = d1.feet + d2.feet; 
   //d2 is another Distance object. 
   d.inches = d1.inches + d2.inches; 
   
   //check whether sum of inches   
  //exceed  12
  if ( d.inches >= 12) 
 	d.feet += 1; 
    
  return d;
 }
 


Similarly, you need to overload '*' for
times.

For change() and add(), you can do it.You need to call :
Code:
 d = d1(x,y)+d2(x) 
 //where x,y are to be replaced.
 


HTH

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > C++ Emer. Help!!!


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT