By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,454 Members | 3,191 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,454 IT Pros & Developers. It's quick & easy.

need help in object orientated programming

P: n/a
Hi,

I need help on my mini project on object orientated programming. The
question goes like this:
A mini-mart has just installed a bar code reader to improve efficiency
at their checkouts.
Assume that the bar code is to access a file that store the product
descriptions, unit price
and quantity of each product sold in the shop. Assume that there are
only 10 products in
this mini-mart.
The format of the product stored in the file is shown below :
Barcode : a text string of 4 numeric character
Product description : a text string of 20 characters
Unit price : a floating point value
Quantity : an integer
Design the necessary classes and member functions to achieve the
following tasks :
a. Read the list of products available in the mini-mart from a text
file.
b. Allow user to enter the bar code of a product via keyboard and the
quantity
purchase during check out.
c. Display the product description, unit price, quantity and the total
cost of all the
products bought by a customer.
d. Update the quantity of each product in stock after a purchase is
done.
e. Write the bar code and product description to a text file if the
level of stock is less
than 10.
f. Continue the program until user press a ‘Q’ to exit.

Please enlighten me on how can i start to write the program?

Thanks alot
Jul 10 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
al******@gmail.com wrote:
I need help on my mini project on object orientated programming. The
question goes like this:
A mini-mart has just installed a bar code reader to improve efficiency
at their checkouts.
Assume that the bar code is to access a file that store the product
descriptions, unit price
and quantity of each product sold in the shop. Assume that there are
only 10 products in
this mini-mart.
The format of the product stored in the file is shown below :
Barcode : a text string of 4 numeric character
Product description : a text string of 20 characters
Unit price : a floating point value
Quantity : an integer
Design the necessary classes and member functions to achieve the
following tasks :
a. Read the list of products available in the mini-mart from a text
file.
b. Allow user to enter the bar code of a product via keyboard and the
quantity
purchase during check out.
c. Display the product description, unit price, quantity and the total
cost of all the
products bought by a customer.
d. Update the quantity of each product in stock after a purchase is
done.
e. Write the bar code and product description to a text file if the
level of stock is less
than 10.
f. Continue the program until user press a ‘Q’ to exit.

Please enlighten me on how can i start to write the program?
Every program should contain the 'main' function, so you can very easily
start to write your program by typing the following in your text editor:

int main()
{
}

If that's not a satisfactory answer, perhaps you should be more specific
on what it is that gives you the _real_ problem. If you have no idea
how to begin at all, perhaps you should talk to your instructor/teacher?

Do you understand the requirement "design the necessary classes"? Which
out of the 6 requirements are unclear? Why do I have to ask you those
leading questions?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 10 '08 #2

P: n/a
On Jul 10, 8:45*am, alck1...@gmail.com wrote:
[do my homework redacted]
You can find a good solution to your problem in the FAQ's at FAQ 5.2

http://www.parashift.com/c++-faq-lit...t.html#faq-5.2
Jul 10 '08 #3

P: n/a
On Jul 10, 11:45*am, alck1...@gmail.com wrote:
Hi,

I need help on my mini project on object orientated programming. The
question goes like this:
A mini-mart has just installed a bar code reader to improve efficiency
at their checkouts.
Assume that the bar code is to access a file that store the product
descriptions, unit price
and quantity of each product sold in the shop. Assume that there are
only 10 products in
this mini-mart.
The format of the product stored in the file is shown below :
Barcode : a text string of 4 numeric character
Product description : a text string of 20 characters
Unit price : a floating point value
Quantity : an integer
Design the necessary classes and member functions to achieve the
following tasks :
a. Read the list of products available in the mini-mart from a text
file.
b. Allow user to enter the bar code of a product via keyboard and the
quantity
purchase during check out.
c. Display the product description, unit price, quantity and the total
cost of all the
products bought by a customer.
d. Update the quantity of each product in stock after a purchase is
done.
e. Write the bar code and product description to a text file if the
level of stock is less
than 10.
f. Continue the program until user press a ‘Q’ to exit.

Please enlighten me on how can i start to write the program?
The first thing I think I would do is get a sense of what the input
and output should look like. Including the files you are supposed to
read from and write to.

Use notebook paper or a word processor document and make something
that looks like a typical program run.

BTW, this question is off topic here. You should probably post on
alt.comp.lang.learn.c-c++ or some such.
Jul 10 '08 #4

P: n/a
<al******@gmail.comwrote:

<extract follows>
I need help on my mini project on object orientated programming. The
question goes like this:
A mini-mart has just installed a bar code reader to improve efficiency
at their checkouts.
Assume that the bar code is to access a file that store the product
descriptions, unit price
and quantity of each product sold in the shop. Assume that there are
only 10 products in
this mini-mart.
The format of the product stored in the file is shown below :
Barcode : a text string of 4 numeric character
Product description : a text string of 20 characters
Unit price : a floating point value
Quantity : an integer
Design the necessary classes and member functions to achieve the
following tasks :
a. Read the list of products available in the mini-mart from a text
file.
b. Allow user to enter the bar code of a product via keyboard and the
quantity
purchase during check out.
c. Display the product description, unit price, quantity and the total
cost of all the
products bought by a customer.
d. Update the quantity of each product in stock after a purchase is
done.
e. Write the bar code and product description to a text file if the
level of stock is less
than 10.
f. Continue the program until user press a ‘Q’ to exit.

Please enlighten me on how can i start to write the program?

<end extract>

We don't know what you have been taught so far, e.g., are you supposed to
use C++ strings or C strings? C arrays or C++ vectors? My guess is that
you are expected to use the C version of things.

Start by defining a struct to hold a record. It is fundamental to most of
the other stuff. You will probably have an array of these structures.

It looks like your instructor got tired of writing before he finished the
specification. There is no means of producing an initial data base (it
wasn't inherited as the scan code is new). There is no means of specifying
the end of one customer and the beginning of another customer. There is no
way of saving the data base at the end of a business day. You might as well
let your imagination take over and finish it per your desires. Sketch the
menu you plan to present to the user. Does it seem complete?

I see only one class, call it DB for data base. It would have a few member
functions; note that there is not a 1:1 correlation between menu items and
member functions. For example, I would subsume 'd' under 'b' and 'e' under
'd'.

Rather than make an issue of the initial data base, it might be simpler to
just create one with the text editor you use to write programs. So it would
not be a line item on the menu.

Obviously if there are things that don't make sense to you in the
assignment, you are in a bad position to start writing a program. Maybe
the instructor covered some of these things that bother me in class.

Jul 10 '08 #5

P: n/a
On Jul 10, 6:46 pm, Victor Bazarov <v.Abaza...@comAcast.netwrote:
alck1...@gmail.com wrote:
I need help on my mini project on object orientated
programming. The question goes like this:
A mini-mart has just installed a bar code reader to improve efficiency
at their checkouts.
Assume that the bar code is to access a file that store the product
descriptions, unit price
and quantity of each product sold in the shop. Assume that there are
only 10 products in
this mini-mart.
The format of the product stored in the file is shown below :
Barcode : a text string of 4 numeric character
Product description : a text string of 20 characters
Unit price : a floating point value
Quantity : an integer
Design the necessary classes and member functions to achieve the
following tasks :
a. Read the list of products available in the mini-mart from a text
file.
b. Allow user to enter the bar code of a product via keyboard and the
quantity
purchase during check out.
c. Display the product description, unit price, quantity and the total
cost of all the
products bought by a customer.
d. Update the quantity of each product in stock after a purchase is
done.
e. Write the bar code and product description to a text file if the
level of stock is less
than 10.
f. Continue the program until user press a ?Q? to exit.
Please enlighten me on how can i start to write the program?
Every program should contain the 'main' function, so you can
very easily start to write your program by typing the
following in your text editor:
int main()
{
}
If that's not a satisfactory answer, perhaps you should be
more specific on what it is that gives you the _real_ problem.
If you have no idea how to begin at all, perhaps you should
talk to your instructor/teacher?
Even before that (and before worrying about whether he can use
std::string or not), he should probably start by doing some
design. Trying to determine what classes may or may not be
necessary, for example. Obviously, some classes will be needed
to represent the different data. I'd start there, and then try
to define the interactions between them, either adding behavior
to the existing classes, or adding additional classes with
behavior to manage the relationships. (There are one or two
points in the specification which are vague, of course, so he'll
probably have to ask for more information. Just like in the
real world:-).)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jul 11 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.