SWT301_-_PE_-_SP_2025_3560.webp
Minthep

SWT301_-_PE_-_SP_2025_3560.webp

  • Media owner Minthep
  • Ngày thêm
Question 2 (3 points): Code Review and Bug Identification
Below is a Java method from the Travel Booking website. Identify 6 errors related to coding
conventions, coding standards, or coding logic.
public class TravelBooking {
String BookingId;
double totalPrice;
int numberOfTravelers;
}
TravelBooking(String id, double price, int travelers) {
Bookingld = id;
totalPrice = price;
numberOfTravelers = travelers;
boolean ConfirmBooking(String paymentMethod) {
}
}
if (paymentMethod == "CreditCard") {
return processPayment(totalPrice);
} else if (paymentMethod.equals("Digital Wallet")) {
return processPayment(totalPrice * 0.98); // 2% discount
return false;
private boolean processPayment(double amount) {
// Simulate payment processing
return amount > 0;
}
String getBookingDetails() {
}
return "Booking ID: " + BookingId + ", Total: " + totalPrice;
Answer requirements:
Identify 6 errors in the above code.
Chưa có bình luận nào.

Thông tin

Category
SWT301
Thêm bởi
Minthep
Ngày thêm
Lượt xem
7,805
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom