Code in C++
Must show: unit testing
------------------------------------
UsedFurnitureItem
- Create a class namedUsedFurnitureItem to represent a usedfurniture item that the store sells.
- Private data members of aUsedFurnitureItem are:
- age (double) // age in years – default valuefor
- brandNewPrice (double) // the original priceof the item when it was brand new
- description (string) // a string descriptionof the item
- condition (char) // condition of the itemcould be A, B, or C.
- size (double) // the size of the item in cubicinches.
- weight (double) // the weight of the item inpounds.
- Private member functions of aUsedFurnitureItem object are
- double CalculateCurrentPrice( ): Current pricedepends on age, brandNewPrice, and condition ofthe used furniture Item. If the item is in A-condition, the currentprice will go down by extra 10% of thebrandNewPrice for each year of its age until 7years (e.g., After the first year, and item with a $100brandNewPrice will cost $90, after 2 years, $ 80,and so on). If the age is greater than 7 years, the price is fixedat 30% of the brandNewPrice. The current price ofB-condition items goes down by extra 15 % of thebrandNewPrice for each year until the5th year. After that, the current price is fixed at 20%of the brandNewPrice. Items with C-condition arepriced at 10% of the brandNewPrice regardless ofage.
- double CalculateShippingCost( ): Shipping costof a UsedFurnitureItem depends on weight, size,and distance. While weight and size are member variables, shippingdistance is provided as an additional argument to this function.Shipping rate is 1 cent per mile for items that are smaller than1000 cubic inches and smaller than 20 pounds. Items with largersize or weight cost 2 cents per mile.
- Public member functions of aUsedFurnitureItem
- Constructors – default and overloaded [default values: age =1.0, brandNewPrice = 10.00, description = “Not availableâ€,condition = ‘A’, size = 1.0, weight = 1.0]
- Accessors (getters)
- Mutators (setters) – You should ensure that invalid (zero ornegative) values do not get assigned to age,brandNewPrice, size orweight data members. An invalid character (otherthan ‘A’, ‘B’ or ‘C’) should not be allowed to be assigned
-------------------------------------
Test Program:
The test program will test each setter (for objects of bothtypes in a sequence) by calling the setter to set a value and thencall the corresponding getter to print out the set value. This testshould be done twice on data members that could be set to invalidvalues (that have numerical or character data type) – once aftertrying to set invalid values and subsequently, once after settingthem to valid values. The data members with string data types(model, description) can betested just once.