Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class User {
- private String userId;
- public User(Long id){
- // Constructor
- this.userId = id.toString();
- }
- public String getNumber(){
- return userId; // return the account number
- }
- public ArrayList getBookings() throws Exception{
- try{
- List dbBookingList = Db.getBookings(userId.trim()); //Get the list of bookings
- ArrayList bookingList = new ArrayList();
- int i;
- for(i=0; i<dbBookingList.size(); i++){
- DbRow dbRow = (DbRow) dbBookingList.get(i);
- Transaction trans = makeTransactionFromDbRow(dbRow);
- transactionList.add(trans);
- }
- return transactionList;
- } catch (SQLException ex){
- // There was a database error
- throw new Exception("Can't retrieve transactions from the database");
- }
- }
- public Transaction makeTransactionFromDbRow(DbRow row){
- double currencyAmountInPounds = Double.parseDouble(row.getValueForField("amt"));
- String product = row.getValueForField(βprodβ);
- return new Transaction(product, currencyAmountInPounds); // return the new Transaction object
- }
- // Override the equals method
- public boolean equals(User o) {
- return o.getNumber() == getNumber(); // check account numbers are the same
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement