Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8121417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:28:58+00:00 2026-06-06T05:28:58+00:00

I’m trying to write two classes, Sale and Register, for my OO class. Here

  • 0

I’m trying to write two classes, Sale and Register, for my OO class. Here are the two headers.

Sale header:

enum ItemType {BOOK, DVD, SOFTWARE, CREDIT};

class Sale
{
public:
Sale();         // default constructor, 
            // sets numerical member data to 0

void MakeSale(ItemType x, double amt);  

ItemType Item();        // Returns the type of item in the sale
double Price();     // Returns the price of the sale
double Tax();       // Returns the amount of tax on the sale
double Total();     // Returns the total price of the sale
void Display();     // outputs sale info (described below)

private:
double price;   // price of item or amount of credit
double tax;     // amount of sales tax (does not apply to credit)
double total;   // final price once tax is added in.
ItemType item;  // transaction type
};

Register header:

class Register{
public:

Register(int ident, int amount);
~Register();
int GetID(){return identification;}
int GetAmount(){return amountMoney;}
void RingUpSale(ItemType item, int basePrice);
void ShowLast();
void ShowAll();
void Cancel();
int SalesTax(int n);

private:

int identification;
int amountMoney;
int listSize;
int numSales;
Sale* sale;
};

In the Register class I need to hold a dynamic array of Sale objects. I’m able to do this. My problem is with the RingUpSale() function in ‘Register’. I need to be able to access and modify the private member data of ‘Sale’ from that function. For instance:

sale[numSales]->item = item;
    sale[numSales]->total = basePrice; // Gets an error
    if(item == CREDIT){
            sale[numSales]->tax = 0; // Gets an error
            sale[numSales]->total = basePrice; // Gets an error
            amountMoney -= basePrice;
    }
    else {
        sale[numSales]->tax = 0.07*basePrice; // Gets an error
        sale[numSales]->total = (0.07*basePrice)+basePrice; // Gets an error
        amountMoney += basePrice;
    }

I don’t know how to make this access possible. Maybe through inheritance or friend structure?

And before you rag on the design of this please keep in mind this is for homework, so there are idiotic restrictions. One of them being I can’t modify the ‘Sale.h’ from what I’ve written. And I can only add more private functions in the ‘Register.h’.

RingUpSale() function description:

  • RingUpSale
    This function allows the item type and base price of a sale to be passed in as parameters. This
    function should store the sale in the sale list, and it should update the amount of money in the
    cash register appropriately. Items that are bought will add money to the register. Remember that
    sales tax must be added to the base price of any item sold. If the sale type is CREDIT, then you
    should deduct the amount from the register.

Also this:

-(Hint: keep in mind that inside the register, you are keeping a dynamic array of Sale objects. This
means that most of these functions will be using this array to do their work — and they can also
call upon Sale class member functions).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:28:59+00:00Added an answer on June 6, 2026 at 5:28 am

    It looks like the Sale::MakeSale() function is intended to take care of these tax calculation details. Given an item and a base price, it would compute the tax (if necessary) and update the total value.

    (I’m assuming that although you can’t modify Sale.h, you can implement Sale.cpp.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.