Flight Data Formatting and Passenger Name Standardization
Business Scenario
Welcome back,Developers!
In the previous lab, we learned about Classes, Objects, Inheritance, and Arrays to create and manage flight records. In this lab, we extend those concepts by implementing Abstraction and the DAO Pattern using an Interface.
Pre-Lab Preparation
Basic Java programming concepts
Classes and objects
Encapsulation (getters and setters)
String manipulation methods
Task 1: Enhancing the Passenger Class
1
Use the Existing Class
Begin with the provided basic Passenger class structure.
2
Add formatName() Method
Create a method to standardize passenger names into a consistent format (e.g., proper case).
3
Update setName() Method
Modify the setter to automatically call formatName() before storing the value.
4
Run and Verify Output
Test the program to ensure that names are correctly formatted and stored
Output:
Task 2: Passport and Validation Handling
1
Modify setPassportNumber() Method
Add validation logic to ensure passport numbers follow the required format and rules
2
Add Masked Passport Feature
Implement a method to display a masked version of the passport number for security purposes
3
Testing
Output:
Run test cases to verify:
Proper validation of passport numbers
Correct masking of sensitive data
Expected program output
Great job!
In this lab, we enhanced an encapsulated Java class by implementing data cleaning, formatting, and validation techniques. We also improved performance using StringBuilder and strengthened data security by masking sensitive information such as passport numbers.
Checkpoint