谁能帮我做两道JAVA的题,我谢谢你们了,关系到这个学期的成绩。

程序设计题:
1. 定义一个描述员工的类Employee,包含姓名name、性别sex和薪水wage三个属性,方法包括构造方法和输出员工信息的方法。
2.(1) 定义商品类Goods,包含单价unitPrice和数量account二个属性,方法包括构造方法和价格计算方法totalPrice()。
(2) 定义VIP会员价格接口VipPrice,包含DISCOUNT属性和reducedPrice()方法。
(3) 定义服装子类Clothing,它继承商品类Goods并实现接口VipPrice,使VIP会员商品价格享受8折优惠,并有服装样式style属性、构造方法和显示服装信息的show方法。
(4)编写一个测试类,创建一种服装(200,1,”男装”),利用show方法输出服装的单价、数量、样式及VIP价格信息。

用JAVA的基本语法做,谢谢了!!急用!!!

1、
//员工类
public class Employee {
private String name;
private String sex;
private double wage;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public double getWage() {
return wage;
}
public void setWage(double wage) {
this.wage = wage;
}
public Employee(){}
public Employee(String name, String sex, double wage) {
this.name = name;
this.sex = sex;
this.wage = wage;
}

public void showInfo(){
System.out.println("员工姓名:"+name);
System.out.println("性别:"+sex);
System.out.println("薪水:"+wage);
}
}
2、
//商品类
public class Goods {
private double unitPrice;
private int account;
public double getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(double unitPrice) {
this.unitPrice = unitPrice;
}
public int getAccount() {
return account;
}
public void setAccount(int account) {
this.account = account;
}
public Goods() {}
public Goods(double unitPrice, int account) {
this.unitPrice = unitPrice;
this.account = account;
}
public double totalPrice(){
return unitPrice*account;
}
}
//VIP价格接口
public interface VipPrice {
double DISCOUNT=0.8;
double reducedPrice();
}
//服装类
public class Clothing extends Goods implements VipPrice {

private String style;
public String getStyle() {
return style;
}
public void setStyle(String style) {
this.style = style;
}
@Override
public double reducedPrice() {
return VipPrice.DISCOUNT*totalPrice();
}
public Clothing(){}
public Clothing(double unitPrice, int account,String style) {
super(unitPrice, account);
this.style=style;
}
public void showInfo(){
System.out.println("服装单价:"+getUnitPrice());
System.out.println("数量:"+getAccount());
System.out.println("样式:"+style);
System.out.println("原价:"+totalPrice());
System.out.println("VIP价格:"+reducedPrice());
}
}
//测试类
public class Test {
public static void main(String[] args) {
Clothing c=new Clothing(200,1,"男装");
c.showInfo();
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2007-12-23
没认真学java吧,最基本的东东,看在50分上,我帮你搞定。
//员工类
public class Goods {
protected float unitPrice;
protected int account;
Goods(long unitPrice,int account){
this.unitPrice=unitPrice;
this.account=account;
}
public float totalPrice(){
return unitPrice*account;
}
}
//VIP接口
public interface VipPrice {
public float DISCOUNT=0.2f;
public float reducedPrice();
}
//Clothing类

public class Clothing extends Goods implements VipPrice{
private String style;
/**
* @param unitPrice
* @param account
*/
Clothing(long unitPrice, int account,String style) {
super(unitPrice, account);
this.style=style;

}
public float reducedPrice() {
return unitPrice*(1-DISCOUNT);

}
public void show(){
System.out.println("The Clothing information:\r\n");
System.out.println("unitPrice="+unitPrice);
System.out.println("account="+account);
System.out.println("VipPrice="+reducedPrice());
System.out.println("Style="+style);
}
public void main(String[] args) {
}

}
//测试类
public class TestClothing {

public static void main(String[] args) {
Clothing c=new Clothing(200,1,"男装");
c.show();
}
}
第2个回答  2007-12-23
//第一题
public class Employee
{
private String name = null;
private String sex = null;
private double wage = 0.0;

public Employee()
{

this.name = "noname";
this.sex = "男";
this.wage = 0;
}

public Employee(String name,String sex,double wage)
{

this.name = name;
this.sex = sex;
this.wage = wage;
}

public void show()
{
System.out.println("姓名:"+this.name+" 性别:"+this.sex+" 工资:"+this.wage);
}

}
第3个回答  2020-05-15
不好意思按错键所以还没有写完就上传了
我重新上传了
说答案相似不一定能上传
所以把后面的给你补上
public
static
void
main(String
[]
args){
Clothing
hs
=
new
Clothing(200,
1,
"男装");
hs.show();
}
相似回答