diff --git a/index.html b/index.html index be6da78c5e9ec9f23846a724d7820f71b1816897..8928afba5dacb53aa1b740edbac9c7a8ffb72970 100644 --- a/index.html +++ b/index.html @@ -1,48 +1,59 @@ - Page Title - - + Page Title + +
- -
-
+ +
+
- + + diff --git a/js/car.js b/js/car.js new file mode 100644 index 0000000000000000000000000000000000000000..324e340b215f43f0cd8c1fc93e62d5b4b8e033b1 --- /dev/null +++ b/js/car.js @@ -0,0 +1,35 @@ +// Classe Bagnole +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; +} + +// Générer l'image de la bécane +Car.prototype.generateImage = function(elt) { + const carImg = document.createElement('img'); + carImg.src = this.image; + carImg.alt = `${this.make} ${this.model}`; + carImg.setAttribute('class','card-img-top'); + + elt.appendChild(carImg); +} + +// Générer les Extra (ul et li) +Extra.prototype.generateExtras = function(elt) { + let unorderedList = document.createElement('ul'); + + for ( let i = 0; i < this.extras.length; i++) { + let line = document.createElement('li'); + line.text = `${this.extras[i].name} ${this.extras[i].price}`; + unorderedList.appendChild(li); + } + + elt.appendChild(unorderedList); +} \ No newline at end of file diff --git a/js/extra.js b/js/extra.js new file mode 100644 index 0000000000000000000000000000000000000000..37f736c8e630a95562657309ebba1f61215343eb --- /dev/null +++ b/js/extra.js @@ -0,0 +1,5 @@ +// Classe Extra +function Extra(name,price) { + this.name = name; + this.price = price; +}