0

I am working on pset 8 and this is what I have tried:
1. In the populate function under the TODO:

PASSENGERS[i].placemark = placemark;
PASSENGERS[i].marker = marker;

2. pseudocode for pickup function:

iterate over passenger array
    var lat = HOUSES[PASSENGERS[passenger].house].lat;
    var lng = HOUSES[PASSENGERS[passenger].house].lng;
    calculate distance from shuttle:
        iterate over seats array
            set shuttle.seats[i].name = passenger's name;
            etc (whatever is suggested in the spec)

But it is not working. Am I in the right direction?

0
1

Think about HOUSES[PASSENGERS[passenger]], what value do you think PASSENGERS[passenger] is returning and do you think it could be used to index a value in HOUSES? Remember also, that HOUSES is an associative array and expects a string; i.e. name of a house on campus.

Firstly, you want to get the latitude and longitude from the passenger. Then compare it to your shuttles coordinates to see if they are within range. The houses on campus have nothing to do with picking up the passengers except for seeing whether or not the passenger wants to go to a house (residence), in which case you can pick them up. If however, they are trying to go somewhere else, they shouldn't be allowed on the bus.

That's all you should think about when using HOUSES in pickup(). If you are still stuck, print out onto the console the values of variables you use and compare them to what you except them to equal.

As for the seats array, you need not set a name attribute to the name of the passenger. Instead, the function that prints the names of the passengers on the bus looks for the seats being equal to null so you should instead have a seat equal to an actual passenger element like PASSENGER[0]. And null if there is no passenger in that seat.

3
  • Oh sorry it was actually HOUSES[PASSENGERS[passenger].house].lat – user2279543 Aug 18 '14 at 16:10
  • ok so should I use getGeometry() and getLatitude() functions? – user2279543 Aug 18 '14 at 16:33
  • Thanks a lot! I figured it out :) – user2279543 Aug 18 '14 at 17:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .