SHARE
TWEET

Untitled

a guest Jun 19th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class User {
  2.     private String userId;
  3.    
  4.     public User(Long id){
  5.         // Constructor
  6.         this.userId = id.toString();
  7.     }
  8.    
  9.     public String getNumber(){
  10.         return userId; // return the account number
  11.     }
  12.    
  13.     public ArrayList getBookings() throws Exception{
  14.         try{
  15.             List dbBookingList = Db.getBookings(userId.trim()); //Get the list of bookings
  16.             ArrayList bookingList = new ArrayList();
  17.             int i;
  18.             for(i=0; i<dbBookingList.size(); i++){
  19.                 DbRow dbRow = (DbRow) dbBookingList.get(i);
  20.                 Transaction trans = makeTransactionFromDbRow(dbRow);
  21.                 transactionList.add(trans);
  22.             }
  23.             return transactionList;
  24.            
  25.         } catch (SQLException ex){
  26.             // There was a database error
  27.             throw new Exception("Can't retrieve transactions from the database");
  28.         }
  29.     }
  30.    
  31.     public Transaction makeTransactionFromDbRow(DbRow row){
  32.         double currencyAmountInPounds = Double.parseDouble(row.getValueForField("amt"));
  33.         String product = row.getValueForField(“prod”);
  34.         return new Transaction(product, currencyAmountInPounds); // return the new Transaction object
  35.     }
  36.    
  37.     // Override the equals method  
  38.     public boolean equals(User o) {
  39.         return o.getNumber() == getNumber(); // check account numbers are the same
  40.     }
  41. }
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top