724 Chapter 7e Create Class Described Uml Directions Given Test Method Enter Using Main C Q37106610

7.24 Chapter 7E

Create the class described by the UML and directions givenbelow. Test each method as you you enter it by using main andcalling it:

CartItem- item: string
– quantity: int
– price: double+CartItem()
+CartItem(item: string, price: double, qty: int)

+getItem(): string
+getPrice(): double
+getQuanitity(): int

+setPrice(price: double): void
+setQuanitity(qty: int): void

+ printItem():void

Create the class using three files – a .h, a .cpp and amain.cpp:

  • Constructor with no arguments
    • Sets strings equal to a null string and numbers equal tozero
  • Constructor with arguments
    • Sets the instance variables to the values passed in
  • Get methods (accessors) return the field that the get refersto
  • Set methods (mutators) set the field to the new values passedin to it
  • printItem
    OR
    OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.