filter method and problems with code

I want to print stundents with corresponding places.what is the problem with this code,and there is one method undone.
Which asks to find list of places given the name of student
i used collections but it gives an error

        import java.util.HashMap;
      import java.util.LinkedList;
      import java.util.List;
      import java.util.Map;






   public class main {

    public static void main(String[] args) {
    handle ha = new handle();

    ha.addStudent("mary", "obama", "katy", "smith", "john");

    ha.addPosition("position1", "katy", "smith");
    ha.addPosition("position2","john", "obama");
    ha.addPosition("position3", "mary", "obama");
    ha.addPosition("position4", "katy", "smith", "john");


    Stundent MaryPlace = ha.getStundent("mary");
    List<Place> placesWithMAry = MaryPlace.getPlace();
    System.out.println(placesWithMAry.get(0).getName()); 
    Place programmerPos = ha.getPlace("position3");
}



public class Place {
    private String name;
    private String[] skillNames;


    public Place(String name, String... skillNames  ) {
        this.name=name;
        this.skillNames=skillNames;
}

    public String getName() {
        return name;
        }
}


public class Stundent {
    String[] names;
    List<Place> places=new LinkedList<>();

    public Stundent(String... names) {
        this.names=names;

    }


    //should provides the list of palces that require that student
    public List<Place> getPlace() {


        return places;
    }


    public String[] getNames() {
        return names;
    }





}
public class handle{
    Map<String,Stundent> students=new HashMap<>();
    Map<String,Place> places=new HashMap<>();


    public void addStudent(String... names)  {

        for(String s:names){

            Stundent c=new Stundent(names);
            students.put(s, c);
            }
            }
    public void addPosition(String name, String... skillNames)  {
        for(String x:skillNames){

            Place p=new Place(name,x);
            places.put(name, p);
            }
            }


    public Stundent getStundent(String name) {


    return students.get(name);


    }
    public Place getPlace(String name) {


        return places.get(name);


        }



}

}


Source: java

Leave a Reply