/
anton.buldygin
/
Contacts_Java
Обзор
Документация
Войти
/
anton.buldygin
/
Contacts_Java
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Topics/Command/Remote control/task-info.yaml
127 строк
3 KB
AntonBuldygin
Initial commit
19 дек 2023, 15:38
19 дек 2023, 15:38
bed9366
Код
Авторство
О чём код?
type: code files: - name: src/Main.java visible: true text: |- import java.util.Scanner; class Client { public static void main(String[] args) { Controller controller = new Controller(); TV tv = new TV(); int[] channelList = new int[3]; Scanner scanner = new Scanner(System.in); for (int i = 0; i < 3; i++) { channelList[i] = scanner.nextInt(); } Command turnOnTV = new TurnOnCommand(tv); /* write your code here */ Command changeChannel; for (int i = 0; i < 3; i++) { /* write your code here */ } Command turnOffTV = new TurnOffCommand(tv); /* write your code here */ } } class TV { Channel channel; void turnOn() { System.out.println("Turning on the TV"); setChannel(new Channel(this, 0)); } void turnOff() { /* write your code here */ } void setChannel(Channel channel) { this.channel = channel; } } class Channel { private TV tv; private int channelNumber; Channel(TV tv, int channelNumber) { /* write your code here */ } void changeChannel() { tv.setChannel(this); System.out.println("Channel was changed to " + channelNumber); } } interface Command { /* write your code here */ } class TurnOnCommand implements Command { /* write your code here */ TurnOnCommand(TV tv) { this.tv = tv; } @Override public void execute() { /* write your code here */ } } class TurnOffCommand implements Command { /* write your code here */ TurnOffCommand(TV tv) { this.tv = tv; } @Override public void execute() { /* write your code here */ } } class ChangeChannelCommand implements Command { private Channel channel; ChangeChannelCommand(Channel channel) { this.channel = channel; } @Override /* write your code here */ } class Controller { private Command command; void setCommand(Command command) { this.command = command; } void executeCommand() { /* write your code here */ } } learner_created: false feedback_link: https://hyperskill.org/learn/step/7768#comment status: Solved feedback: message: <html>Correct solution</html> time: "Tue, 19 Dec 2023 11:25:37 UTC" record: -1 submission_language: java17