java简单的管理系统(商品)源码public class Product{//实体
//设置属性
private int Pid;
private String name;
private double price;
private int count;
//⽆参构造
public Product(){}
//有参构造
public Product(int pid, String name, double price, int count) {
super();
Pid = pid;
this.name = name;
this.price = price;
}
//重写toString⽅法
@Override
public String toString() {
System.out.println("商品编号" + "\t商品名称" +"\t商品价格" + "\t库存价格");
return Pid +"\t"+name + "\t"+price +"\t"+count;
}
public int getCount() {
return count;
}
public void tCount(int count) {
}
public int getPid() {
return Pid;
}
public interface ProductDAO {//接⼝
//添加商品
boolean addProduct (Product product);
//显⽰所有商品信息
void showAllProduct ();
//通过ID查找某⼀件商品信息
分期付款合同Product finfProductById (int id);
//根据id进⾏⼊库操作
boolean inPrduct (int id , int num);
//根据id进⾏出库操作
boolean outPrduct (int id , int num);
//根据id删除元素
boolean deleteProduct (int id);
}
public class ProductDAOImpl implements ProductDAO{//实现类
//创建⼀个集合对象
ArrayList products = new ArrayList();
ArrayList products = new ArrayList();
@Override
public boolean addProduct(Product product) {
// TODO Auto-generated method stub
boolean add= products.add(product);
return add;
}
@Override
public void showAllProduct() {
// TODO Auto-generated method stub
for(int i = 0;i<products.size();i++){
System.out.(i));
}
}
@Override
public Product finfProductById(int id) {
冰柜的温度怎么调
// TODO Auto-generated method stub
//遍历数据
for(int i =0;i<products.size();i++){
//找到对应的商品
Product product = (Product) (i);
Pid()==id){
return product;
}
老母鸡}
return null;
}
@Override
public boolean inPrduct(int id, int num) {
/
/ TODO Auto-generated method stub
for(int i=0;i<products.size();i++){
Product product = (Product) (i);
Pid()==id){
//获取原来的数据
int numOld = Count();
//更新数据
int numNew = numOld + num;
//给对象的数据进⾏更新
product.tCount(numNew);
}
}
return true;
}
@Override
public boolean outPrduct(int id, int num) {
// TODO Auto-generated method stub
for(int i=0;i<products.size();i++){
Product product = (Product) (i);
Pid()==id){
//获取原来的数据
int numOld = Count();
if(numOld<num){
System.out.println("库存不⾜请重新输⼊:"); }el{
//更新数据
//更新数据
int numNew = numOld - num;
//给对象的数据进⾏更新
product.tCount(numNew);
}
}
}
return true;
}
@Override
public boolean deleteProduct(int id) {
// TODO Auto-generated method stub
for(int i=0;i<products.size();i++){
Product product = (Product) (i);
Pid()==id){
System.out.println("删除成功");
}
}
return true;
}
public static void showMainMenu(){//界⾯
boolean falg = true; //定义⼀个boolean的值让循环停下来
Scanner input = new Scanner(System.in); //⽤来接收数字 Scanner input1 = new Scanner(System.in); //⽤来接收字符
//创建并保存对象
Product product1 = new Product();
//创建对象调⽤⽅法
ProductDAOImpl pdi = new ProductDAOImpl();
while(falg){
System.out.println("**********⼩商品系统*************");
System.out.println("1:录⼊商品信息");
System.out.println("2:展⽰所有商品信息");
System.out.println("3:根据id查找商品");
System.out.println("4:商品⼊库");
System.out.println("5:商品出库");
System.out.println("6:删除指定商品");
System.out.println("7:退出系统");
System.out.print("请输⼊你的选择:");
int num = Int();
switch(num){
ca 1:{
System.out.print("请输⼊id");
int pid = Int();
System.out.print("请输⼊名称");
String pname = Line();
System.out.print("请输⼊价格");
double price = Double();
System.out.print("请输⼊数量");
int count = Int();
product1 = new Product(pid, pname, price, count); pdi.addProduct(product1);
}break;
}break;
经历的英语ca 2:{怎样做鸡翅
三峡移民精神
pdi.showAllProduct();
}break;
ca 3:{
System.out.println("请输⼊要查找的id");
int num1 = Int();
pdi.finfProductById(num1);
System.out.println(product1);
}break;
ca 4:{
System.out.println("请选择您要⼊库的商品id:"); int num2 = Int();
System.out.println("请选择您要⼊库的数量:"); int num3 = Int();
pdi.inPrduct(num2, num3);
}break;
ca 5:{
System.out.println("请选择您要出库的商品的id:"); int num2 = Int();
System.out.println("请选择您要出库的数量");
int num3 = Int();
pdi.outPrduct(num2, num3);
}break;
ca 6:{
System.out.println("请选择您要删除的商品信息"); int num2 = Int();
第三国度电影
pdi.deleteProduct(num2);
}break;
ca 7:{
System.out.println("欢迎下次使⽤");
falg = fal;
}break;
}
}
}
public class ProductTest {//product测试⽂本 public static void main(String[] args) { MainMenu.showMainMenu();
}
小小班几岁可以上
}