Advertisement
ChrisCGalbraith

Untitled

Apr 23rd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. package com.github.chriscgalbraith.structalg;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Map;
  5. import java.util.TreeMap;
  6.  
  7. public class Dealership {
  8.    
  9.     private TreeMap<String, TreeMap<String, ArrayList<Car>>> myDoubleTree;
  10.     String make;
  11.     String model;
  12.     Car car;
  13.    
  14.     public void addMake() {
  15.         myDoubleTree.put(make, new TreeMap<>());
  16.     }
  17.    
  18.     public void removeMake() {
  19.        
  20.     }
  21.    
  22.     public void addModel() {
  23.         myDoubleTree.get(make).put(model, new ArrayList<>());
  24.     }
  25.    
  26.     public void addCar() {
  27.         myDoubleTree.get(make).get(model).add(car);
  28.     }
  29.    
  30.     public void displayMakes() {
  31.         for (Map.Entry<String, TreeMap<String, ArrayList<Car>>> entry : myDoubleTree.entrySet())
  32.         {
  33.           System.out.println(entry.getValue());
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement