diff --git a/index.html b/index.html index be6da78c5e9ec9f23846a724d7820f71b1816897..ac51c3b085a5063cc7b6166a8d038e20994efae0 100644 --- a/index.html +++ b/index.html @@ -32,19 +32,33 @@ + + diff --git a/js/car.js b/js/car.js new file mode 100644 index 0000000000000000000000000000000000000000..5d2c305e8149aef98a06cbaf4a4d5d4b215bfc3e --- /dev/null +++ b/js/car.js @@ -0,0 +1,37 @@ +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.tabExtras = 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.tabExtras.length; i++ ) + { + const extra = document.createElement ( "li" ); + extra.textContent = this.tabExtras[i].name + " " + this.tabExtras[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..01d35a0c7a084a62857bd6aaf5a93fbf00850982 --- /dev/null +++ b/js/extra.js @@ -0,0 +1,6 @@ +function Extra (name, price ) +{ + this.name = name; + this.price = price; +} +