用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

源程序

2014-12-24 作者: 云代码会员举报

[java]代码库

import java.util.*;
public class ShangPin {        //商品类
	private String Snum;
	private String Sname;
	private Date data;
	private String CJname;
	

	public ShangPin(){
		Snum="";
		Sname="";
		CJname="";
	}
	
	@SuppressWarnings("deprecation")
	public ShangPin(String Snum,String Sname,String CJname,int year,int month,int day){
		this.Snum=new String(Snum);
		this.Sname=new String(Sname);
		this.CJname=new String(CJname);
		this.data=new Date(year-1900,month-1,day);
	}
	
	public void setSnum(String Snum){this.Snum=Snum;}
	public void setSname(String Sname){this.Sname=Sname;}
	public void setCJname(String CJname){this.CJname=CJname;}
	@SuppressWarnings("deprecation")
	public void setdata(int year,int month,int day){
		this.data=new Date(year-1900,month-1,day);
	}
	
	public String getSnum(){return Snum;}
	public String getSname(){return Sname;}
	public String getCJname(){return CJname;}
	public Date data(){return data;}
	
	public String toString(){
		return "Snum:"+Snum+"\nSname:"+Sname+"\nChuChangday:"+String.format("%tF",data)+"\nCJname:"+CJname;
	}
	
}

public class ShiPin extends ShangPin{        //食品类
	private int BaoZhiQi;
	private String changfen;
	
	public ShiPin(){
		super();
		BaoZhiQi=0;
		changfen="";
	}
	public ShiPin(String Snum,String Sname,String CJname,int year,int month,int day,int BaoZhiQi,String changfen){
		super(Snum,Sname,CJname,year,month,day);
		this.BaoZhiQi=BaoZhiQi;
		this.changfen=new String(changfen);
	}
	public void setBaoZhiQi(int BaoZhiQi){this.BaoZhiQi=BaoZhiQi;}
	public void setchengfen(String changfen){this.changfen=changfen;}
	
	public int getBaoZhiQi(){return BaoZhiQi;}
	public String getchangfen(){return changfen;}
	
	public String toString(){
		return "食品:"+super.toString()+"\nBaoZhiQi:"+BaoZhiQi+"天"+"\nchangfen:"+changfen+"\n\n";
	}
	
}
public class FuZhuang extends ShangPin{
	String XingHao;
	String MianLiao;
	
	public FuZhuang(){
		super();
		XingHao="";
		MianLiao="";
	}
	public FuZhuang(String Snum,String Sname,String CJname,int year,int month,int day,String XingHao,String MianLiao){
		super(Snum,Sname,CJname,year,month,day);
		this.XingHao=new String(XingHao);
		this.MianLiao=new String(MianLiao);
	}
	public void setXingHao(String XingHao){this.XingHao=XingHao;}
	public void setMianLiao(String MianLiao){this.MianLiao=MianLiao;}
	
	public String getXingHao(){return XingHao;}
	public String getMianLiao(){return MianLiao;}
	
	public String toString(){
		return "服装:"+super.toString()+"\nXingHao:"+XingHao+"\nMianLiao:"+MianLiao+"\n\n";
	}
	
}
	
public class TestShangPin {

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		ShangPin []sp=new ShangPin[2];
		sp[0]=new ShiPin("0001","面包","肯德基",2014,10,20,2,"面粉、鸡肉");
		sp[1]=new FuZhuang("1001","T恤","凡客",2014,9,10,"XL","纯棉");
		System.out.print(sp[0]);
		System.out.print(sp[1]);
	}

}


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...