COMP1409Lab6-a2017-04 - COMP 1409 Lab 6-a In-class lab In...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
COMP 1409 Lab 6-a In-class lab In this lab you will re-use class RetailItem and create a new class called CashRegister to simulate the sale of a retail item. Declare this symbolic constant at the top of your class public static final double TAX_RATE = 0.06; Here are the relevant attributes of class CashRegister: RetailItem item int quantitySold Provide a constructor. The constructor uses the appropriate mutator (set) methods to initialize the fields. The constructor takes two parameters to initialize the instance variables. Provide an accessor and mutator for each instance variable. The mutator for the quantity sold validates the passed parameter and uses it only if it is positive. The mutator for the RetailItem field validates the passed parameter and if null creates a new RetailItem object using the default constructor for the RetailItem class. If the parameter is not null it is assigned to the instance variable. Provide a method called calculateSubtotal(). This method calculates and returns the subtotal cost which is the quantity sold multiplied by
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern