Question: Given the following Javascript program I wrote ( Homework 5 ) : class Product { constructor ( name , priceRange ) { this.name = name;
Given the following Javascript program I wrote Homework :
class Product
constructorname priceRange
this.name name;
this.priceRange priceRange;
getPriceRange
return this.priceRange;
class ElectronicsProduct extends Product
constructorname priceRange, warrantyPeriod, powerConsumption
supername priceRange;
this.warrantyPeriod warrantyPeriod;
this.powerConsumption powerConsumption;
getWarrantyPeriod
return this.warrantyPeriod;
getPowerConsumption
return this.powerConsumption;
Testing the classes
let objProduct new ProductPhone$;
let objElectronicsProduct new ElectronicsProductLaptop$ years", W;
console.logProduct:;
console.logName: objProduct.name;
console.logPrice Range:", objProduct.getPriceRange;
console.log
Electronics Product:";
console.logName: objElectronicsProduct.name;
console.logPrice Range:", objElectronicsProduct.getPriceRange;
console.logWarranty Period:", objElectronicsProduct.getWarrantyPeriod;
console.logPower Consumption:", objElectronicsProduct.getPowerConsumption;
The task is the following:
In Homework You wrote a program on the inventory management system for a retail store
with classes Product as the superclass and ElectronicsProduct as the subclass.
Modify the same program for exception handling. Please make sure to take all the values from the
user using scanner.
If the value entered from user is string or character in pricerange, it should show input mismatch
exception points
If warrantyperiod is or then output meaningful error messages if an exception occurs.
points
If power consumption is digits, show exception error message, please enter correct number for
power consumption. points
Create a variable status in ElectronicsProduct class to store whether the product is available or not.
This variable stores yes or no values from the user. If the user enters any word example null other
than yes or no show exception message. points
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
