# Summer: Assignment 4 - Coding Lab ## Objective You are the Director of Transportation in a newly founded state named Few York. Your current priority is establishing a subway system for your residents. You looked to the MTA for inspiration and decided to create 6 subway lines. The subway lines are grouped into subway colors. You hired a team of Software Engineers to create an app for your new subways system. Help them create the perfect app for your residents. The Few York Subway app needs the following objects: * Subway Line Object * Subway Line Group Object Use your knowledge of creating and manipulating variables, arrays, and objects to complete the steps below. --- ## Steps --- ## Part 1: Subway Line Objects [8 pts] Subway Line objects are used to store information about a subway line. Subway Line objects have the following keys: * `lineName` (string) - This is the name of the Subway Line * `lineColor` (string) - This is the color group the Subway Line belongs to * `boroughsServiced` (array of strings) - This is an array of the names of the Boroughs this Subway Line passes through. * `lineStops` (array of strings) - This is an array of the names of the Subway Stations this Subway Line stops at. --- 1. Create 6 variables with the following names: `line1`, `line2`, `line3`, `lineA`, `lineC`, `lineE`. **Each variable is for an object that you will create in the following steps. Read carefully to assign the correct objects to the correct variables**. --- 2. The `line1` Subway Line object is for the 1 Train. The name of this subway line is `1 Train`. The color of this subways line is `red`. This subway line services TWO boroughs (`"BX", "MAN"`). This subway line stops at the following stations: 1. Penn Station 2. Times Square 3. 231 St. - **[1.3: 1 pt]** --- 3. The `line2` Subway Line object is for the 2 Train. The name of this subway line is `2 Train`. The color of this subways line is `red`. This subway line services THREE boroughs (`"BX", "MAN", "BK"`). This subway line stops at the following stations: 1. Penn Station 2. Times Square 3. 231 St. 4. Wakefield 5. Church Ave. 6. Bergen St. - **[1.3: 1 pt]** --- 4. The `line3` Subway Line object is for the 3 Train. The name of this subway line is `3 Train`. The color of this subways line is `red`. This subway line services THREE boroughs (`"BX", "MAN", "BK"`). This subway line stops at the following stations: 1. Penn Station 2. Times Square 3. 231 St. 4. Wakefield 5. W 145 St 6. W 135 St - **[1.3: 1 pt]** --- 5. The `lineA` Subway Line object is for the A Train. The name of this subway line is `A Train`. The color of this subways line is `blue`. This subway line services THREE boroughs (`"MAN", "BK", "QNS"`). This subway line stops at the following stations: 1. Far Rockaway 2. Liberty Ave. 3. Utica Ave. 4. High St. 5. 23 St. 6. Inwood - **[1.3: 1 pt]** --- 6. The `lineC` Subway Line object is for C Train. The name of this subway line is `C Train`. The color of this subways line is `blue`. This subway line services TWO boroughs (`"MAN", "BK"`). This subway line stops at the following stations: 1. 96 St. 2. Nostrand Ave. 3. Euclid Ave. - **[1.3: 1 pt]** --- 7. The `lineE` Subway Line object is for E Train. The name of this subway line is `E Train`. The color of this subways line is `blue`. This subway line services TWO boroughs (`"MAN", "BK", "QNS"`). This subway line stops at the following stations: 1. 96 St. 2. Nostrand Ave. 3. Euclid Ave. 4. Forest Hills 5. Queensborough Bridge 6. Jamaica Center - **[1.3: 1 pt]** --- 8. Type `console.log("PART 1 - Train Line Objects\n")` --- 9. Use `console.log()` and `object dot notation` to output the `lineName`, `lineColor`, `boroughsServiced`, and `lineStops` of the 6 `Subway Line` objects you created. - **[1.5: 2 pts]** --- ## Part 2: Subway Line Group Objects [8 pts] Subway Line group objects have the following keys: * `groupColor` (string) * `groupLines` (array of Subway Line objects) - This array holds `Subway Line Objects` * **NOTE: The `groupLines` key will play a significant role in Part 3** --- 1. Create 2 variables with the following names: `redTrainLines`, `blueTrainLines` - **[1.1: 2 pts]** --- 2. The `redTrainLines` object is for ALL `Subway Line` objects that are `red`. The `groupColor` is `Red`. The `groupLines` key should be an `EMPTY ARRAY` when the object is first created. - **[1.3: 1 pt]** --- 3. The `blueTrainLines` object is for ALL `Subway Line` objects that are `blue`. The `groupColor` is `Blue`. The `groupLines` key should be an `EMPTY ARRAY` when the object is first created. - **[1.3: 1 pt]** --- 4. Use the `push()` method to add ALL of apprropriate `Subway Line` Objects to the `groupLines` key of the `redTrainLines` Subway Line Group object. - **[1.3: 1 pt]** --- 5. Use the `push()` method to add ALL of apprropriate `Subway Line` Objects to the `groupLines` key of the `blueTrainLines` object. - **[1.3: 1 pt]** --- 6. Type `console.log("\n\nPART 2 - Subway Line Group Objects\n")` --- 7. Use `console.log()` and `object dot notation` to output the `groupColor`, and the `groupLines` keys of the `blueTrainLines` AND `redTrainLines` objects. - **[1.5: 2 pts]** --- ## Part 3: A Line Expansion [8 pts] The A Line has increased its stops to service more neighborhoods and Boroughs. In this part, you are to make changes to the lineA object. **HOWEVER, it is not as straightforward as your think. You will access the `lineA` object through another object. Think back to part 2.** --- 1. Type `console.log("\n\nPART 3 - BEFORE Expansion\n")` --- 2. Use `console.log()`, the **`blueTrainLines`** object, and `object dot notation` to output the following: - [ ] The `groupColor` key of the `blueTrainLines` object. - [ ] The `lineName`, `boroughsServiced`, and `lineStops` of the `lineA` object. You **MUST** use the **`blueTrainLines`** object to do this. **HINT** In Part 2, you used the push() method to add the `lineA` object to the `groupLines` key of the `blueTrainLines` object. You can use the `blueTrainLines` object to access the `lineA` object. - **[1.3: 2 pt]** - **[1.5: 1 pt]** --- 3. Use the appropriate `Subway Line Group` object, `array indexing` and the appropriate `array method` to add "BX" to the list of Boroughs that the `lineA` object services. - **[1.5: 1 pt]** --- 4. Use the appropriate `Subway Line Group` object, `array indexing` and the appropriate `array method` to add "Pelham Bay" and "Baychester Ave" to the list of stops that the `lineA` object makes. - **[1.5: 1 pt]** --- 5. Type `console.log("\n\nPART 3 - AFTER Expansion\n")` --- 6. Use `console.log()`, the **`blueTrainLines`** object, and `object dot notation` to output the following: - [ ] The `groupColor` key of the `blueTrainLines` object. - [ ] The `lineName`, `boroughsServiced`, and `lineStops` of the `lineA` object. You **MUST** use the **`blueTrainLines`** object to do this. **HINT** In Part 2, you used the push() method to add the `lineA` object to the `groupLines` key of the `blueTrainLines` object. You can use the `blueTrainLines` object to access the `lineA` object. - **[1.2: 2 pt]** - **[1.5: 1 pt]**