Computers and Technology

Your task will be to create a class called Distance, in the files distance. h and distance. cpp, which will involve a variety of operator overloads. A Distance object will store a quantity of distance in terms of miles, yards, feet, and inches. You will overload some basic operators for use with these objects including arithmetic, comparison, and insertion/extraction operators. These operators must work even for large distances (e. g. thousands of miles) and should not overflow the capacity of the storage variables (int) unless the number of miles is very close to the upper limit of int storage. Program Details and Requirements The Distance class must allow for storage of a non-negative quantity of distance in terms of miles, yards, feet, and inches using integer precision. All values should be non-negative. The data should always be maintained in a simplified form. For example, if you have 14 inches, this should be expressed as 1 foot and 2 inches. You should create appropriate member data in your class, all of which must be private.
Remember that there are 12 inches in a foot, 3 feet in a yard, and 1760 yards in a mile. The only limit on the number of miles is that imposed by int storage (e. g. ~2 billion for 32 bit int)
Public Interface
1. Constructors
The class should have a default constructor (no parameters) which should initialize the object so that it represents the distance 0.
The class should have a constructor with a single integer parameter which represents a quantity of inches. This should be translated into the appropriate notation for a Distance object. Note: this will be a conversion constructor that allows automatic type conversions from int to Distance. If the parameter is negative, default the Distance object to represent 0.
The class should have a constructor that takes 4 parameters representing the miles, yards, feet, and inches to use for initializing the object. If any of the provided values are negative, default the Distance object to represent 0. If any of the provided values are too high (e. g. 13 inches), simplify the object to the appropriate representation.
Examples: Distance t; Distance s (1234); // creates an object of 0 miles, 0 yards, 0 feet, 0 inches // creates an object of 0 miles, 34 yards, 0 feet, 10 inches

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:00, ozzy55
Create a word problem that involves calculating the volume and surface area of a three-dimensional object. cube: surface area 6 s2 , volume s3
Answers: 3
image
Computers and Technology, 22.06.2019 16:10, Olaf2018
Drag each label to the correct location on the imagelist the do’s and don’ts of safeguarding your password. keep yourself loggedin when you leave your computer. don’t write your password down and leave it whereothers can find it. share your password with your friends. each time you visit a website, retain the cookies on your computer. use a long password with mixed characters.
Answers: 1
image
Computers and Technology, 23.06.2019 10:00, thezbell
What is estimated time of arrival (eta)? a device that measures the acceleration (the rate of change of velocity) of an item and is used to track truck speeds or taxi cab speeds a gps technology adventure game that posts the longitude and latitude location for an item on the internet for users to find a north/south measurement of position the time of day of an expected arrival at a certain destination and is typically used for navigation applications
Answers: 3
image
Computers and Technology, 25.06.2019 08:10, yangyang718
Rom also called main memory or system memoryis used to stor the essential parts of the operating while the computer is running / true or false
Answers: 2
Do you know the correct answer?
Your task will be to create a class called Distance, in the files distance. h and distance. cpp, whi...

Questions in other subjects: