Home > Back-end >  O guide the Java
O guide the Java

Time:09-19

To perfect the product class, this class is used to manage product's name, unit price and inventory quantity, can according to the user to enter the product name and purchase quantity calculation of the corresponding amount, in the main function of simulated a few commodities (by keyboard input), and implement a program menu type, various user any purchased goods process,
The class product
{
String tag;//product name
double price;//unit price
Int quantity;//inventory quantity
Public:
//the constructor

//buy buy a commodity function, and returns false said inventory quantity is not enough, or update the inventory quantity, and calculate the cost
//attributes related functions, such as the inventory adjustment, shows the inventory quantity, etc.
}
  • Related