Topics: Constructor Instance, Methods, Method Calls, Inheritance, Static Methods
- Create a html file with your name like john.html
- Add current code to that file:
<!DOCTYPE html>
<html>
<body>
<script>
// your code here
</script>
</body>
</html>
-
Create class named
TrafficLight
. -
Add
color
andaddress
to it. -
Create an instance
myTL
and setcolor
tored
andaddress
toAvenue 1
-
Add a method named
getColor
to getcolor
and call with console.log to show into console. -
Add a method name
canGo
that checks color and if it isgreen
returns true, else false. -
Create class named
VIPTrafficLight
inherits fromTrafficLight
-
Add field
SpecialEffects
to this class. -
Create an instance named
myVIP
and set SpecialEffects todotted
. -
Add method getSpecialEffects() to return the effect.
-
Add method setSpecialEffects() to set the effect. If it not
dotted
,solid
ordashed
do not set and logNo valid Effect
.
Send Pull Request. Check how to deliver your code: https://codingwithbasir.com/how-to-deliver-projects/
Download Learn JavaScript eBook from https://codingwithbasir.com/learn-javascript