Leds
Submit solution
Points:
10
Time limit:
5.0s
Memory limit:
256M
Author:
Problem types
Allowed languages
C#, C++, Go, Java, Python
Implementa els mètodes switchOn() i switchOff() de la classe Led.
switchOn()canvia la variablestateatrueswitchOff()canvia la variablestateafalse
Fer servir el següent codi com a plantilla:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
class Led {
boolean state;
void draw(){
if(state){
System.out.print("(*)");
} else {
System.out.print("( )");
}
}
}
public class Main {
public static void main(String[] args) {
Led l1 = new Led();
Led l2 = new Led();
l1.draw();
l2.draw();
l1.switchOn();
System.out.println();
l1.draw();
l2.draw();
l2.switchOn();
System.out.println();
l1.draw();
l2.draw();
l1.switchOff();
System.out.println();
l1.draw();
l2.draw();
}
}
Input Format
-
Constraints
-
Output Format
-
Sample Output 0
( )( )
(*)( )
(*)(*)
( )(*)
Autoria: Gerard Falcó
CC BY-NC-SA 4.0