Advertisement
Guest User

Untitled

a guest
Jul 13th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import './App.css';
  3.  
  4. class Vehicle {
  5.   make: string;
  6.   model: string;
  7.   year: number;
  8.   image: string;
  9.   description: string;
  10.   seats: number;
  11.   driveStyle: string;
  12.   constructor(make: string, model: string, year: number, image: string, description: string, seats: number, driveStyle: string) {
  13.     this.make = make;
  14.     this.model = model;
  15.     this.year = year;
  16.     this.image = image;
  17.     this.description = description;
  18.     this.seats = seats;
  19.     this.driveStyle = driveStyle;
  20.   }
  21.  
  22.   getCarInfo() {
  23.     return [this.make, this.model, this.year, this.image, this.description, this.seats, this.driveStyle];
  24.   }
  25. }
  26. const DogCarDesc = 'This is a wonderful new car by Mitsubishi\, it sports a \.1 horsepower engine as well as a fur coating\. No dogs were harmed in the creation of this masterpiece of both art and engineering\. This is a true feat of humanity you are seeing right now\.';
  27. const CatCarDesc = 'A car as ferocious as a feline, designed by designers, so you know it\'s good';
  28. const DogCar = new Vehicle('Mitsubishi', 'Dog Petter Max', 2017, './img/mitsubishidog.jpg', DogCarDesc, 4, 'FWD');
  29. const CatCar = new Vehicle('Mazda', 'Cat Scratch Supreme', 2012, './img/catcar.jfif', CatCarDesc, 8, 'AWD');
  30. console.log(DogCar.getCarInfo());
  31.  
  32.  
  33. let cars = new Map();
  34. cars.set('DogCar', DogCar.getCarInfo());
  35. cars.set('CatCar', CatCar.getCarInfo());
  36.  
  37. class carTable {
  38.  
  39.   createTable = () => {
  40.     let table = [];
  41.  
  42.     for (let car of cars.entries()) {
  43.       console.log(car);
  44.       table.push(
  45.         <div className="VehicleListing" >
  46.           <div className="HiddenDiv">
  47.             <div className="ListContainer">
  48.               <p className="ListHeader">
  49.                 {car[1][2]} {car[1][0]} {car[1][1]}
  50.               </p>
  51.               <img src={car[1][3]} className="ListPicture"></img>
  52.               <div className="HiddenP">
  53.                 <p className="HiddenInfo">Seats: {car[1][5]}</p>
  54.                 <p className="HiddenInfo">Driving Style: {car[1][6]}</p>
  55.               </div>
  56.               <p className="ListDescription">{car[1][4]}</p>
  57.             </div>
  58.           </div>
  59.         </div>
  60.  
  61.       )
  62.     }
  63.     return table
  64.   }
  65. }
  66.  
  67. const tableto = new carTable();
  68. const finalCars = tableto.createTable();
  69. console.log(finalCars);
  70.  
  71. const App: React.FC = () => {
  72.  
  73.   return (
  74.     <div className="App">
  75.       <div className="Welcome">
  76.         <h3 className="Title">Welcome to Vehicles, we hope you find this helpful in your search for a new car!</h3>
  77.       </div>
  78.       <hr />
  79.       {finalCars}
  80.     </div>
  81.  
  82.   );
  83. }
  84.  
  85. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement