I have something to code here is the instructions
Design and implement the class DAY that implements the day of the week in a program, The class DAY, should store the day such as Sunday, Monday, Tuesday, Wednesday, Thursday, Friday and Saturday. The program should be able to perform the following operations on an object of type DAY:
a.Set the day.
b. Print the day.
c. Return the day.
d. Return the next day.
e. Return the previous day.
f. Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add four days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday. So the user needs to input how many days he wants to add.
g. Add the appropriate constructor.
Write the definitions of the methods to implement the operations of the class Day, as defined in a through g.
I have written a code but when i try to run it nothing happens only blank page is shown on html, so here is my code.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
let prompt = require('prompt-sync')();
class MyDay{
constructor(day,noOfDay){
this.weekdays = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
this.day = day;
this.noOfDay = noOfDay;
}
set setDays(day){
this.day = day;
}
set noOfDays(param){
this.noOfDay = param;
}
get getDay(){
return this.day;
}
get prevDay(){
let day = this.weekdays.indexOf(this.day);
if(day == 0){
return this.weekdays[this.weekdays.length - 1];
}
return this.weekdays[day - 1];
}
get nextDay(){
let day = this.weekdays.indexOf(this.day);
if(day == 6){
return this.weekdays[0];
}
return this.weekdays[day + 1];
}
get returnDay(){
let day = this.weekdays.indexOf(this.day);
let x = (parseInt(day) + parseInt(this.noOfDay)) % 6; //If
let y = (parseInt(day) + parseInt(this.noOfDay)) % 7; //If
if((parseInt(day) + parseInt(this.noOfDay)) < 7){
return this.weekdays[x];
}
return this.weekdays[y];
}
}
let myDay = new MyDay();
let day = prompt("Enter the day: ");
myDay.setDays = day;
console.log(`Today is ${myDay.getDay}`);
console.log(`The previous day is: ${myDay.prevDay}`);
console.log(`The next day is: ${myDay.nextDay}`);
let noDays = prompt("Enter number of days: ");
myDay.noOfDays = noDays;
console.log(`The day after ${noDays} days is ${myDay.returnDay}`);
</script>
</body>
</html>
i tried coding all the instructions but my problem is that nothing is shown when i run it on web only blank page, please help me ty.