package www
public class product {
private proname;
public String getproname(){
return proname;
}
public void setproname(String proname){
this.proname=proname;
}
package www
public class market{
private String marketname;
private product []=productarr;
public String marketname(){
return marketname;
}
public void setmarketname(String marketname){
this.marketname=marketname;
}
public String getproductarr(){
return productarr;
}
public String setproductarr(product [] productarr){
this.productarr=productarr;
}
product sell(String name){
for(int i=0;i<productarr.length;i++){
if(productarr[i].getproname.equalsIgnore(name)){
return productarr[i];
}
}return null;
}
}
package www
public class person{
private String personname;
public String getpersonname(){
return personname;
}
public void setpersonname(String personname){
this.personname=personname;
}
product shopping(market market,String name);{
return market.sell(name);
}
}
package www
import java.util.Scanner;
pblic class shopping{
Scanner sc=new Scanner(System.in);
product p1=new product();
product p1=new product();
product p1=new product();
product p1=new product();
product p1=new product();
p1.proname="电视机";
p2.proname="洗衣机";
p3.proname="豆浆机";
p4.proname="空调机";
p5.proname="吹风机";
market m=new market;
System.out.println("尊敬的顾客朋友,请问你想去的超市是:")
String T;
T=sc.nextLine;
m.setmarketname(T);
System.out.println("欢迎来到"+m.getmarketname+"超市购物!!!");
m.productarr(new product[]{p1,p2,p3,p4,p5});
person p=new person();
System.out.println("请输入你的会员名:'')
String N;
N=sc.nextLine;
p.setpersonname(N);
System.out.println("超市有以下商品:");
System.out.println(" 电视机,洗衣机,豆浆机,空调机,吹风机");
System.out.println("请输入你想要购买的商品");
String shopname;
shopname=sc.nextLine;
product result=p.shopping(m,shopname);
if(result!=null){
System.out.println(p.getpersonname+"在"+m.getmarketname+"超市买到了"+result.getproname);
}
else{
System.out.println(p.setpersonname+"什么也没买到!!!白跑了一趟!!!");
}
}