diff --git a/index.html b/index.html index be6da78c5e9ec9f23846a724d7820f71b1816897..c5964d957dc1f75a7e07eea8c65116fe50adccd0 100644 --- a/index.html +++ b/index.html @@ -32,22 +32,43 @@ + + + diff --git a/js/car.js b/js/car.js new file mode 100644 index 0000000000000000000000000000000000000000..7ee715e40fcea53622d02ab9cb4b56a7885369d5 --- /dev/null +++ b/js/car.js @@ -0,0 +1,38 @@ +function Car ( image, make, model, description, price, category, year, mileage , extras ) +{ + this.image = image; + this.make = make; + this.model = model; + this.description = description; + this.price = price; + this.category = category; + this.year = year + this.mileage = mileage + this.extras = extras; +} + +Car.prototype.generateImage = function ( elt ) +{ + const img = document.createElement ( "img" ); + + img.src = this.image; + img.alt = this.make + ' ' + this.model; + + img.classList.add ( 'card-img-top' ); + + elt.appendChild ( img ); +} + +Car.prototype.generateExtras = function ( elt ) +{ + const liste = document.createElement ( "ul" ); + + for ( let i = 0; i < this.extras.length; i++ ) + { + const extra = document.createElement ( "li" ); + extra.textContent = this.extras[i].name + " " + this.extras[i].price; + liste.appendChild ( extra ); + } + + elt.appendChild ( liste ); +} \ No newline at end of file diff --git a/js/extra.js b/js/extra.js new file mode 100644 index 0000000000000000000000000000000000000000..110029592d4ab85bcc39c68bca50272fc497c6ed --- /dev/null +++ b/js/extra.js @@ -0,0 +1,5 @@ +function Extra ( name, price ) +{ + this.name = name; + this.price = price; +} \ No newline at end of file