-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.html
20 lines (20 loc) · 1.47 KB
/
task.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<h2>Lightbulb</h2>
<html>
<head></head>
<body>
<p>Here's a class <code class="java">Lightbulb</code>. It has only one attribute that represents its state: whether it's on or off. </p>
<p>Create a method <code class="java">change_state</code> that changes the state of the lightbulb. In other words, the method turns the light on or off depending on its current state. The method doesn't take any arguments and prints a corresponding message: <strong><code class="java">Turning the light on</code></strong> if it was off, and <strong><code class="java">Turning the light off</code></strong> if it was on. </p>
<p>Inside the method, you are also supposed to change the value of the attribute <code class="java">state</code>.</p>
<p><button class="btn-sm btn-outline-secondary" onclick="getElementById('hint-622').style.display='inline'"> Hint </button> </p>
<div id="hint-622" style="display:none;">
To produce the correct result, inside the
<code class="java">change_state</code> method check the current state of the lightbulb by accessing the
<code class="java">state</code> attribute.
</div>
<p></p>
</body>
</html><br><br><font color="gray">Memory limit: 256 MB</font><br><font color="gray">Time limit: 15 seconds</font><br><br>
<b>Caution</b><br><br>
You may see errors in your code or execution results due to missing context. Don’t worry about it, just write the solution and press Check.
<br><br>
<a href="https://hyperskill.org/learn/step/6981">Show topic summary</a>