<file_sep>//import {Mobile} from './Mobile';

// let movil_1:Mobile = new Mobile('movil 1','nokia 3210', 'nokia', 150,'gris',false,5545,3);
// let movil_2:Mobile = new Mobile('movil 2','iphone 3g', 'apple', 300,'blanco',false,6978,40);
// let movil_3:Mobile = new Mobile('movil 3','samsung galaxy', 'samsung', 500,'azul',true,9854,120);

// console.log(movil_1);
// console.log(movil_2);
// console.log(movil_3);

// movil_1.is5G = true;
// movil_1.cameraNumber = 4;

// console.log(movil_1);<file_sep># OOPReview
clase de prueba
<file_sep>import {Mobile} from './Mobile';
import {MobileLibrary} from './MobileLibrary';

let movil_1:Mobile = new Mobile('movil 1', 'nokia 3210', 'nokia', 1, 'gris', false, 0, 3);
let movil_2:Mobile = new Mobile('movil 2', 'iphone 3g', 'apple', 3,'blanco',false, 1, 40);
let movil_3:Mobile = new Mobile('movil 3', 'samsung galaxy', 'samsung', 3,'azul', true, 1, 120);
let movil_4:Mobile = new Mobile('movil 4', 'huawei mate 40 pro', 'huawei', 5, 'negro', true, 2, 1199);
let moviles:Mobile[] = [movil_1, movil_2, movil_3, movil_4];
let library:MobileLibrary = new MobileLibrary('library', 'madrid', moviles);

let p_print = ():void =>    {
    console.log(library.getName());
    console.log(library.getLocation());
    console.log(library.getMobiles());
    console.log(library.getTotalPrice());
    console.log('');
}

p_print();

library.setName('<NAME>');
library.setLocation('teruel');
library.setMobiles([movil_1,movil_2]);
library.setTotalPrice(123);

p_print();

library.printLibrary();//el precio total es 123 porque antes lo he cambiado con el setter.<file_sep>import {Mobile} from './Mobile';

export class MobileLibrary  {

    private name:string;
    private location:string;
    private mobiles:Mobile[];
    private totalPrice:number;

    constructor(name:string, location:string, mobiles:Mobile[]) {
        this.name = name;
        this.location = location;
        this.mobiles = mobiles;
        this.totalPrice = this.totalPriceCalculation();
    }

    public getName():string {
        return this.name;
    }
    public getLocation():string {
        return this.location;
    }
    public getMobiles():Mobile[]    {
        return this.mobiles;
    }
    public getTotalPrice():number   {
        return this.totalPrice;
    }

    public setName(name:string):void    {
        this.name = name;
    }
    public setLocation(location:string):void    {
        this.location = location;
    }
    public setMobiles(mobiles:Mobile[]):void    {
        this.mobiles = mobiles;
    }
    public setTotalPrice(totalPrice:number):void    {
        this.totalPrice = totalPrice;
    }

    private totalPriceCalculation():number   {
        let totalPrice = 0;
        for(let i=0;i<this.mobiles.length;i++)  {
            totalPrice += this.mobiles[i].getPrice();
        }
        return totalPrice;
    }

    public printLibrary():void  {
        console.log('This is all my mobiles');
        for(let i=0;i<this.mobiles.length;i++)  {
            this.mobiles[i].printMobile();
        }
        console.log('..........................');
        console.log(`Price overall: ${this.totalPrice}`);
    }
}<file_sep>import {Mobile} from './Mobile';

let movil_1:Mobile = new Mobile('movil 1','nokia 3210', 'nokia', 150,'gris',false,5545,3);
let movil_2:Mobile = new Mobile('movil 2','iphone 3g', 'apple', 300,'blanco',false,6978,40);
let movil_3:Mobile = new Mobile('movil 3','samsung galaxy', 'samsung', 500,'azul',true,9854,120);

console.log(movil_1);
console.log(movil_2);
console.log(movil_3);

movil_1.setIs5G(true);
movil_1.setCameraNumber(4);

console.log(movil_1);

let moviles:Mobile[] = [movil_1,movil_2,movil_3];
for(let i=0;i<moviles.length;i++)   {
    moviles[i].printMobile();
}