2

POO en JavaScript

Ponciano
PonceGL
29444

Creando objetos con la constructor integrando imágenes, template literals, enlaces, agregando el numero de estrellas de acuerdo a la calificación de la película.

<!DOCTYPE html><html><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><linkrel="stylesheet"href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"><scriptsrc="https://kit.fontawesome.com/e15999dd07.js"crossorigin="anonymous"></script><linkrel="stylesheet"href="style.css"><title>POO en JavaScript</title></head><body><divclass="container"><h1class="text-center">POO en JavaScript</h1><sectionclass="row mt-5 p-3 d-flex justify-content-between align-items-center"id="section"></section></div><scriptsrc="main.js"></script></body></html>
*{
    margin: 0;
    padding: 0;
}

body{

}

.pelicula{
    width: 23%;
    height: 620px;
    cursor: pointer;
    background-image: linear-gradient(to top, #30cfd0 0%, #330867 100%);
    border-radius: 10px;
    position: relative;
}

.title{
    font-size: 18px;
    font-weight: 700;
}

.fa-star{
    color: #fff;
}

.description{
    font-size: 13px;
}

.peliculaa{
    width: 90%;
    position: absolute;
    bottom: 2%;
    left: 5%;
}

@media screen and (max-width: 900px){
    .pelicula{
        width: 30%;
        height: 560px;
    }
}

@media screen and (max-width: 780px){
    .pelicula{
        height: 580px;
    }
}

@media screen and (max-width: 580px){
    .pelicula{
        width: 47%;
        height: 615px;
    }
}

@media screen and (max-width: 450px){
    .pelicula{
        width: 90%;
        height: 715px;
    }
}

@media screen and (max-width: 380px){
    .pelicula{
        width: 97%;
        height: 700px;
    }
}
const section = document.getElementById('section');

classPelicula{
    constructor(img, title, valor, info, url, id){
        this.img = img;
        this.title = title;
        this.valor = valor;
        this.info = info;
        this.url = url;
        this.id = id;
    }

    crear(){

        section.innerHTML += `
            <div class="p-2 mx-auto my-4 text-center pelicula">
                <imgclass="img-fluid rounded"src="${this.img}"alt=""><pclass="text-center mt-3 mb-0 title">${this.title}</p><divclass="calification d-flex justify-content-star align-items-center py-2"id="${this.id}"></div><pclass="description mb-0 mt-2 text-justify">
                    ${this.info}
                </p><aclass="btn btn-info"href="${this.url}"target="_blank"><iclass="fas fa-play"></i></a></div>`;

        let estrellas = document.getElementById(this.id);

        for (let index = 1; index <= this.valor; index++) {
            estrellas.innerHTML += `
                 <i class="fas mx-1 fa-star"></i>`;
        }
    }
    
};

classSerieextendsPelicula {
    constructor(title, id, cap){
        super(title, id);
        this.cap = cap
    }
    reproducirCapitulo(){
        return `Reproduciendo ${this.title} Capitulo: ${this.cap}`;
    }
}

const avengers = new Pelicula('https://rb.gy/okjgrp', 'Avengers Endgame', 4, 'Después de la devastadora lucha contra Thanos, el universo queda en ruinas. Con la ayuda de los aliados restantes...', 'https://rb.gy/hocfmg', 'avengerEndG');

const spiderMan = new Pelicula('https://rb.gy/qadaeo', 'Spider-Man: Lejos de casa', 3, 'Luego de los eventos de Avengers Endgame, Peter Parker viaja con sus compañeros a Europa donde debe prepararse...', 'https://rb.gy/vz2opr', 'SpiderMHomeComing');

const banker = new Pelicula('https://rb.gy/3gzq1l', 'The Banker', 3, 'En los años 60 dos emprendedores afroamericanos contratan y preparan a un hombre blanco para que se haga pasar...', 'https://rb.gy/msl3t2', 'banker2020');

const starWars = new Pelicula('https://rb.gy/t4fmsj', 'Star Wars: El ascenso de Skywalker', 2, 'Los miembros sobrevivientes de la resistencia se enfrentan a la Primera Orden una vez más, y el legendario conflicto...', 'https://rb.gy/dpaym3', 'sWarsSkywalker');

avengers.crear();
spiderMan.crear();
banker.crear();
starWars.crear();
Escribe tu comentario
+ 2