Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Vehicle parseLine(String line) throws InvalidFormatException {
- String[] parts = line.split("\t");
- if (parts.length != 5 || parts.length != 7) {
- throw new IllegalArgumentException("Wrong number of components");
- }
- String type = parts[0];
- if ("car".equals(type)) {
- return newCar(parts);
- } else if ("motorbike".equals(type)) {
- return newMotorbike(parts);
- } else if ("truck".equals(type)) {
- return newTruck(parts);
- }
- throw new InvalidFormatException ("Unknown type of vehicle");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement