Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Allows input of unique cars into the museum.
- */
- import java.util.*;
- public class CarMuseum implements Measurable
- {
- private ArrayList<String> cars;
- public static int count = 0;
- public CarMuseum(String input)
- {
- cars = new ArrayList<String>();
- String[] arr = input.split(",", 0);
- cars.add(arr[0]);
- count++;
- for(String a : arr)
- {
- for(int i = 1; i < cars.size() + 1; i++)
- {
- if(a == cars.get(i - 1))
- {
- break;
- }
- else if(i == cars.size())
- {
- cars.add(a);
- count++;
- }
- }
- }
- }
- /**
- Returns the count of cars
- @return the count of cars in the museum
- */
- public double getMeasure()
- {
- return (double)count - 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment