Facebook
From Kacper, 5 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 228
  1. public class BookRental {
  2.         String id;
  3.         String customerName;
  4.  
  5.         ...
  6. }
  7.  
  8. public class BookRentals {
  9.         private Vector rentals;
  10.         public String getCustomerName(String rentalId) {
  11.             for (int i = 0; i < rentals.size(); i++) {
  12.                         BookRental rental = (BookRental) rentals.elementAt(i);
  13.                         if (rental.getId().equals(rentalId)) {
  14.  
  15.                                 return rental.getCustomerName(); }
  16.                 }
  17.  
  18.                 throw new RentalNotFoundException();
  19.         }
  20. }
  21.  
  22. public class RentalNotFoundException extends Exception {
  23.         ...
  24. }

Replies to Int1 rss

Title Name Language When
Re: Int1 Kacper java 5 Years ago.