Question
Code: Exercise SupplierName: Status: ON OFF Type: LCD LED Plasma classDevice{ constructor(supplierName,status){ this ._supplierName=supplierName; this ._status=status; } getsupplierName(){ return this ._supplierName; } setsupplierName(newSupplierName){ this ._supplierName=newSupplierName;
Code:
classDevice{
constructor(supplierName,status){
this._supplierName=supplierName;
this._status=status;
}
getsupplierName(){
returnthis._supplierName;
}
setsupplierName(newSupplierName){
this._supplierName=newSupplierName;
}
getstatus(){
returnthis._status;
}
setstatus(status){
this._status=status;
}
//twobasicmethods
enable(){
}
disable(){
}
}
classVideoDeviceextendsDevice{
constructor(supplierName,serialNumber,status,type){
super(supplierName,serialNumber,status);
this._type=type;
}
gettype(){
returnthis._type;
}
settype(newType){
if(newType){
this._type=newType;
}
}
}
letvideoDeviceArray=[];
letlb1=newVideoDevice("somename1",0,"LCD");
letlb2=newVideoDevice("somename2",1,"LED");
letlb3=newVideoDevice("somename3",0,"Plasma");
videoDeviceArray.push(lb1);
videoDeviceArray.push(lb2);
videoDeviceArray.push(lb3);
letcurrentIndex=0;
vari=0;
renderSelected(videoDeviceArray[currentIndex]);
functionnextItem(){
currentIndex++;
if(currentIndex>=videoDeviceArray.length){
currentIndex--;
}
renderSelected(videoDeviceArray[currentIndex])
}
functionprevItem(){
currentIndex--;
if(currentIndex<0){
currentIndex=0;
}
renderSelected(videoDeviceArray[currentIndex])
}