Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1.  
  2. //Constructor funtion 4 the car object
  3. function Car(cid,name,model,year,color,weight)
  4. {
  5. this.cid = cid;
  6. this.name = name;
  7. this.model = model;
  8. this.year = year;
  9. this.color = color;
  10. this.weight = weight;
  11. this.csource = {'city':'Anaheim','zip':'92804'};
  12. this.cdestination = {'city':'Los Angeles','zip':'90210'};
  13.  
  14. this.drawcar = function(){
  15. var longstring = '
  16. <div>
  17. <h3>'+this.name+'</h3>
  18. <div><a href="#" onclick="'+this.cid+'.driveforward();">Drive</a> <a href="#" onclick="car1.drivereverse();">Reverse</a></div>
  19. <span id="car1" class="carspanbox"><i class="fas fa-car-side fa-7x"></i></span>
  20. </div>
  21. ';
  22. };
  23.  
  24. this.driveforward = function(){
  25. $('#'+this.cid).animate({'padding-left':'100px'},'fast');
  26.  
  27. };
  28.  
  29. this.drivereverse = function(){
  30. $('#'+this.cid).animate({'padding-left':'-100px'},'slow');
  31.  
  32. };
  33.  
  34. }
  35. //We create new instances of the Car object
  36. var car1 = new Car('car1','Honda','CRV','2015','black','1550Kg');
  37. var car2 = new Car('car2','Honda','Accord','2010','black','1100Kg')
  38. var car3 = new Car('car2','Nissan','Sentra','2018','yellow','1610Kg')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement