求Java 高手赐教啊!!!! 20

ProgrammingAssignemnt11.InthisPA,youfirstneedtostudycarefullytheRentalExample.Thencon... Programming Assignemnt 1

1. In this PA, you first need to study carefully the Rental Example. Then consider the following requirements:

Northwest Airlines want to develop a new system for the WorldPerks program. In this program, each passenger

has one unique WorldPerks number plus their name. There is three types of status for each passenger who joins the

program: normal, silver, and gold. After travelling with NWA, the system should update the mileage for the

passenger as follows: 1) Normal passenger: update the mileage by the actual travel miles; 2) Silver

passenger: update the mileage by 1.5 * the actual travel miles; 3) Gold passenger: update the mileage by 2 * the

actual travel miles.

2. To implement the above requirements, you need to have the following requirements

Using Eclipse/Java to implement the above program;
Using Inheritance/Polymorphism instead of any conditional statement in your program.

3. How to test your program. The PA1_INPUT file is used to test your program. So your program structure should

be compatible with the test file.

class Testfile {
public static void main(String[] args) {

WorldPerks aProgram = new WorldPerks();

Normal_Customer john = new Normal_Customer("john", 10001); // 10001 is the WorldPerks number
Silver_Customer marry = new Silver_Customer("marry", 10002);
Gold_Customer joe = new Gold_Customer("joe", 10003);

aProgram.addMembers(john);
aProgram.addMembers(marry);
aProgram.addMembers(joe);

john.update_mileage(12000);
marry.update_mileage(23000);
john.update_mileage(2000);
marry.update_mileage(32000);
joe.update_mileage(4000);
joe.update_mileage(21000);

aProgram.printAllCustomerMilege();
// You should print all Cusotmer's mileage infor as the following format:
// john: WorldPerks Number is XXXX and mileage is XXXXXXX;
// marry: WorldPerks Number is XXXXX and mileage is XXXXXXX;
// joe: WorldPerks Number is XXXXX and mileage is XXXXXX;
}
}
展开
 我来答
wsljjyz
2010-05-30 · TA获得超过200个赞
知道答主
回答量:143
采纳率:0%
帮助的人:147万
展开全部
public abstract class Customer {
protected String name;
protected int number;
protected double mileage;
public Customer(String name,int num){
this.name=name;
this.number=num;
}
public abstract void update_mileage(double mile);
public void print(){
System.out.println(name+":WorldPerks Number is "+number+" and mileage is "+getMileage());
}
public abstract double getMileage();
}

public class Normal_Customer extends Customer {

public Normal_Customer(String name, int num) {
super(name, num);
}

@Override
public void update_mileage(double mile) {
this.mileage=mile;
}

@Override
public double getMileage() {
return mileage;
}

}

public class Silver_Customer extends Customer {

public Silver_Customer(String name, int num) {
super(name, num);
}

@Override
public void update_mileage(double mile) {
this.mileage=mile;
}

@Override
public double getMileage() {
return 1.5*mileage;
}

}

public class Gold_Customer extends Customer {

public Gold_Customer(String name, int num) {
super(name, num);
}

@Override
public void update_mileage(double mile) {
this.mileage=mile;
}

@Override
public double getMileage() {
return 2*mileage;
}

}

import java.util.ArrayList;

public class WorldPerks {
ArrayList<Customer> lists;
public WorldPerks(){
lists=new ArrayList<Customer>();
}
public void addMembers(Customer customer){
lists.add(customer);
}
public void printAllCustomerMilege(){
int len=lists.size();
for(int i=0;i<len;i++)
lists.get(i).print();
}
}
pingia
2010-05-30 · TA获得超过569个赞
知道小有建树答主
回答量:697
采纳率:100%
帮助的人:768万
展开全部
发过了 哎 晕 你就不会先搜索下?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式