ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 23 May 2017 My Price 9.00

Draw a UML class diagram for an ItemToPurchase class

The question and project is in the attached file to make it easier to read but I will also post it right below also.

 

 

Step 1. (Design) Draw a UML class diagram for an ItemToPurchase class with the following specifications:

  • private data members (fields)
    • String itemName - Initialized in default constructor to "none"
    • double itemPrice - Initialized in default constructor to 0.0
    • int itemQuantity - Initialized in default constructor to 0
  • Default constructor (zero parameter)
  • A three-parameter constructor with parameters for item name, price, and quantity
  • public member methods (mutators & accessors)
    • setName() & getName()
    • setPrice() & getPrice()
    • setQuantity() & getQuantity()
    • double getSubtotal(): returns itemPrice * itemQuantity
    • void display():  display item information. See sample run for format. Price and subtotal should be displayed with 2 digits after the decimal point.

 

Each setXXX() should have return type void and take a parameter matching the type of the data member it sets.  Each getXXX() should return the corresponding data member.

 

Step 2. Build the ItemToPurchase class. 

 

Step 3. Provide a driver class ShoppingCartPrinter.  In its main(),

  • Prompt user for item 1, create an object of the ItemToPurchase class by invoking the default constructor, and then call setXXX() to set the values of its data members. 
  • Prompt user for item 2, and create an object of the ItemToPurchase class by invoking the three-parameter constructor    
  • Call display() of each item to print item information. 
  • Call appropriate methods of the two objects to retrieve subtotal, add together, and output

 

Step 1. (Design) Draw a UML class diagram for an ItemToPurchase class with the following speciFca±ons:private data members (Felds)oString itemName - Ini±alized in default constructor to "none"odouble itemPrice - Ini±alized in default constructor to 0.0oint itemQuan±ty - Ini±alized in default constructor to 0Default constructor (zero parameter)A three-parameter constructor with parameters for item name, price, and quan±typublic member methods (mutators & accessors)osetName() & getName()osetPrice() & getPrice()osetQuan±ty() & getQuan±ty()odouble getSubtotal(): returns itemPrice * itemQuan±tyovoid display():display item informa±on. See sample run for format. Price and subtotalshould be displayed with 2 digits a²er the decimal point.Each setXXX() should have return type void and take a parameter matching the type of the data memberit sets.Each getXXX() should return the corresponding data member.Step 2. Build the ItemToPurchase class.Step 3. Provide a driver class ShoppingCartPrinter.In its main(),Prompt user for item 1, create an object of the ItemToPurchase class by invoking the defaultconstructor, and then call setXXX() to set the values of its data members.Prompt user for item 2, and create an object of the ItemToPurchase class by invoking the three-parameter constructorCall display() of each item to print item informa±on.Call appropriate methods of the two objects to retrieve subtotal, add together, and output

Attachments:

Answers

(11)
Status NEW Posted 23 May 2017 12:05 AM My Price 9.00

-----------

Not Rated(0)