Skip to content

Instantly share code, notes, and snippets.

@AlanJui
Created May 17, 2014 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlanJui/7ef9440fd3d4db19a32a to your computer and use it in GitHub Desktop.
Save AlanJui/7ef9440fd3d4db19a32a to your computer and use it in GitHub Desktop.
package tw.ccc99.bpandsvc;
/**
* Created by AlanJui on 2014/5/17.
*/
import java.util.*;
public class RentABike {
private String storeName;
final List<Bike> bikes = new ArrayList<Bike>();
public RentABike(String storeName) {
this.storeName = storeName;
bikes.add(new Bike("Shimano", "Roadmaster", 20, "11111", 15, "Fair"));
bikes.add(new Bike("Cannondale", "F2000 XTR", 18, "22222", 12, "Excellent"));
bikes.add(new Bike("Trek", "6000", 19, "33333", 12.4, "Fair"));
}
@Override
public String toString() {
return "RentABike: " + storeName;
}
public List<Bike> getBikes() {
return bikes;
}
public Bike getBike(String serialNo) {
Iterator<Bike> iter = bikes.iterator();
while (iter.hasNext()) {
Bike bike = iter.next();
if (serialNo.equals(bike.getSerialNo())) return bike;
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment