该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
rogramming Assignemnt 2
1. In this PA, you need to apply state pattern to implement the following requirements from PA1:
Northwest Airlines want to develop a new system for the WorldPerks program. In this program, each passengerhas 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.
and you also consider the following requirements:
The status of a customer can be changed by calling methods upgrade() or downgrade(). When a change is made, the status of a customer is either upgraded or downgraded by one level. The upgrade relation between these status is normal -> silver -> gold while the downgrade relationship is opposite. The initial status of a customer is normal. After the status of a customer is updated, the mileage computation is based on the above requirements given for PA1. Also, method update() can take a negative integer to decrease the mileage based on the above requirements.
2. To implement the above requirements, you need to have the following requirements
Using Eclipse/Java to implement the above program; Using a class diagram to show the structure of your program; Avoid any usage of conditional statements in your program. Use requires and effects clauses to specify each method.
3. How to test your program. The PA2_INPUT file is used to test your program. So your program structure should be compatible with the test file.