Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Constructor funtion 4 the car object
- function Car(cid,name,model,year,color,weight)
- {
- this.cid = cid;
- this.name = name;
- this.model = model;
- this.year = year;
- this.color = color;
- this.weight = weight;
- this.csource = {'city':'Anaheim','zip':'92804'};
- this.cdestination = {'city':'Los Angeles','zip':'90210'};
- this.drawcar = function(){
- var longstring = '
- <div>
- <h3>'+this.name+'</h3>
- <div><a href="#" onclick="'+this.cid+'.driveforward();">Drive</a> <a href="#" onclick="car1.drivereverse();">Reverse</a></div>
- <span id="car1" class="carspanbox"><i class="fas fa-car-side fa-7x"></i></span>
- </div>
- ';
- };
- this.driveforward = function(){
- $('#'+this.cid).animate({'padding-left':'100px'},'fast');
- };
- this.drivereverse = function(){
- $('#'+this.cid).animate({'padding-left':'-100px'},'slow');
- };
- }
- //We create new instances of the Car object
- var car1 = new Car('car1','Honda','CRV','2015','black','1550Kg');
- var car2 = new Car('car2','Honda','Accord','2010','black','1100Kg')
- var car3 = new Car('car2','Nissan','Sentra','2018','yellow','1610Kg')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement