So We will create a java program but i don't know how to start it. We should use OOP in this one. And there should be minimum of 3 classes (including the main)..

Buy n’ Sell

An electronics and appliance store would like to install a kiosk for customer use. The kiosk allows the customer to take a look at available products for purchase or to sell his or her used but not defective gadget or appliance. You are asked to write a program for the said kiosk.

The program should do the following:
1.) Prompts the user if he or she wishes to buy or sell a product
2.) If the customer wants to buy, display available products for purchase
3.) Before user picks a product for purchase, prompts the user first for amount of cash in hand.
4.) After transaction, displays the products bought, cash paid, and change.
5.) If the user wants to sell a product, prompts user what type of product to sell.
6.) Prompts user for amount of the product to sell.
7.) After transaction, displays the product sold, amount of product, and payment from the transaction

There is the problem. I hope you can help me on HOW TO START my program.. Any ideas please?

Recommended Answers

All 4 Replies

What I like to do while taking on a new project is drawing out exactly how my program wil work, as in using flow chart for my logic flow, since it should use OOP concepts, draw out the classes/object you are going to create, how they are going to interact with each other. Designing the GUI.. all that type of stuff.

Can you help me please? what are the classes that I needed? is it right if i create a sell class and a buy class? and what will i put in the sell class? please I'm really confused in this OOP thing...

Yeah have a promptScreen class, that obviously asks the user if he or she wants to buy or sell. Then make two other classes called buyScreen and sellScreen. so if the user clicks on the "buy" option in the promptScreen class a JFrame will pop up, being the buyScreen class. in the buyScreen class then display the products..etc etc. It's realy quite easy. Just devide the your assignment questions up like so:

promptScreen class:
1.) Prompts the user if he or she wishes to buy or sell a product

buyScreen class:
2.) If the customer wants to buy, display available products for purchase
3.) Before user picks a product for purchase, prompts the user first for amount of cash in hand.
4.) After transaction, displays the products bought, cash paid, and change.

sellScreen class:
5.) If the user wants to sell a product, prompts user what type of product to sell.
6.) Prompts user for amount of the product to sell.
7.) After transaction, displays the product sold, amount of product, and payment from the transaction

Eazi peazi..

In OO design classes represent things, and methods represent actions. (OK, this is the very simplified version!). So a class "sell" or "buy" is probably a bad idea, although Deans "buyScreen" and "sellScreen" are OK because they represent bits of GUI.
However, this is all a bit cart-before-the-horse.
Look at the problem description for the nouns that refer to the key elements - eg "product" "customer" - these are possible classes. Look at the key attributes they have - eg a product has a price, a customer has an amount of cash - these will be possible instance variables for these classes. Finally look at the verbs in the problem description - eg buy, sell - these will be candidates for methods (eg class Customer has a "sell" method that takes a Product as a parameter and updates the Customer's cash.
Finally, design a user interface that uses these classes and methods to achieve the desired results.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.