SHARE
TWEET

Untitled

a guest Jan 24th, 2020 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2. class City{
  3.     constructor(str){
  4.     let strArray = str.split(",")
  5.     this.city = strArray[0];
  6.     this.state = strArray[1];
  7.     this.latitude = strArray[2];
  8.     this. longitude = strArray[3];
  9.   }
  10.   print(){
  11.     console.log("hi, " + this.city + " " + this.state + " " + this.latitude  + " " + this.longitude);
  12.   }
  13. }
  14. class CityMap{
  15.   cities = [];
  16.   constructor(str){
  17.     let strArray = str.split(";")
  18.     for(let i = 0; i < strArray.length; i ++){
  19.       let temp = new City(strArray[i]);
  20.       this.cities.push(temp);
  21.     }
  22.   }
  23.   print(){
  24.     this.cities.forEach(function(item, index, array){
  25.       item.print();
  26.     });
  27.   }
  28. }
  29. let cityMap = new CityMap('"Nashville, TN", 36.17, -86.78;"New York, NY", 40.71, -74.00;"Atlanta, GA", 33.75, -84.39;"Denver, CO", 39.74, -104.98;"Seattle, WA", 47.61, -122.33;"Los Angeles, CA", 34.05, -118.24;"Memphis, TN", 35.15, -90.05;');
  30. cityMap.print();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top