Created
May 17, 2014 10:00
-
-
Save AlanJui/7ef9440fd3d4db19a32a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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