?? seatunittest.java
字號:
public class SeatUnitTest
{
/*
This class white-box tests objects of the Seat class.
Comment out code where appropriate.
*/
public static void main (String args[])
{
Seat s1 = new Seat (1, 2);
Seat s2 = new Seat (3, 4);
// Test 1 - test of constructor
System.out.println("\n\t\tTest 1");
s1.displaySeatInfo();
s2.displaySeatInfo();
/*
// Test 2: try to free a free seat - ERROR
System.out.println("\n\t\tTest 2");
s1.changeSeatStatus(0, "Smith");
s1.displaySeatInfo();
// Test 3: reserve a seat
System.out.println("\n\t\tTest 3");
s1.changeSeatStatus(1, "Smith");
s1.displaySeatInfo();
// Test 4: free a reserved seat
System.out.println("\n\t\tTest 5");
s1.changeSeatStatus(0, "Smith");
s1.displaySeatInfo();
// Test 5:reserve a seat that is already reserved - ERROR
System.out.println("\n\t\tTest 6");
s1.changeSeatStatus(1, "Smith");
s1.changeSeatStatus(1, "Brown");
s1.displaySeatInfo();
// Test 6: book a free seat
System.out.println("\n\t\tTest 7");
s1.changeSeatStatus(2, "Brown");
s1.displaySeatInfo();
System.out.println("\t\tTakings: "+s1.getTakings());
// Test 7: try to reserve a booked seat - ERROR
System.out.println("\n\t\tTest 8");
s1.changeSeatStatus(2, "Smith"); // first, book the seat
s1.changeSeatStatus(1, "Brown");
s1.displaySeatInfo();
System.out.println("\t\tTakings: "+s1.getTakings());
// Test 8: Cancel a booked seat (check takings)
System.out.println("\n\t\tTest 10");
s1.changeSeatStatus(2, "Smith"); // first, book the seat
s1.changeSeatStatus(0, "Smith");
s1.displaySeatInfo();
System.out.println("\t\tTakings: "+s1.getTakings());
// Test 9:try to book a reserved seat (name mismatch) - ERROR
System.out.println("\n\t\tTest 11");
s1.changeSeatStatus(1, "Smith"); // first, reserve the seat
s1.changeSeatStatus(2, "Brown");
s1.displaySeatInfo();
System.out.println("\t\tTakings: "+s1.getTakings());
// Test 10 - book a reserved seat (names match)
System.out.println("\n\t\tTest 12");
s1.changeSeatStatus(1, "Smith"); // first, reserve the seat
s1.changeSeatStatus(2, "Smith");
s1.displaySeatInfo();
System.out.println("\t\tTakings: "+s1.getTakings());
// Test 13: try to book a seat that is already booked - ERROR
System.out.println("\n\t\tTest 13");
s1.changeSeatStatus(2, "Smith"); // first, book the seat
s1.changeSeatStatus(2, "Brown");
s1.displaySeatInfo();
System.out.println("\t\tTakings: "+s1.getTakings());
// Test 14: re-sell a cancelled seat, increasing takings
System.out.println("\n\t\tTest 14");
s1.changeSeatStatus(2, "Smith"); // first, book the seat
s1.changeSeatStatus(0, "Smith"); // now, cancel the booking
s1.changeSeatStatus(2, "Brown"); // resell the seat
s1.displaySeatInfo();
System.out.println("\t\tTakings: "+s1.getTakings());
*/
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -