Computers and Technology, 22.02.2021 19:10 stormmesa1
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
Answers: 1
Computers and Technology, 22.06.2019 09:00
Create a cell reference in a formula by typing in the cell name or a. right-clicking the cell. b. clicking the cell. c. clicking the column where the cell is located. d. clicking the row where the cell is located.
Answers: 1
Computers and Technology, 22.06.2019 15:30
When creating a budget, log fixed expenses before income. after income. after savings. at the top.
Answers: 1
Computers and Technology, 23.06.2019 09:30
The place where the extended axis of the earth would touch the celestial sphere is called the celestial
Answers: 1
Computers and Technology, 23.06.2019 19:30
Of the following pieces of information in a document, for which would you most likely insert a mail merge field?
Answers: 3
Your task will be to create a class called Distance, in the files distance. h and distance. cpp, whi...
Engineering, 11.07.2019 01:10
Engineering, 11.07.2019 01:10
Engineering, 11.07.2019 01:10
Social Studies, 11.07.2019 01:10
Physics, 11.07.2019 01:20
Mathematics, 11.07.2019 01:20
Spanish, 11.07.2019 01:20