Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "BaSyx / Introductory Examples / Java / Example Heater"
< BaSyx | Introductory Examples
(Created page with "= Heater stub = This stub code realizes an interface to an oven and a dummy implementation for the example code that can be executed without any hardware. The heaterinterf...") |
m (→Heater stub) |
||
Line 4: | Line 4: | ||
− | The | + | The heater interface defines common interface functions to control the oven. |
<syntaxhighlight lang="java" style="margin-left: 4em"> | <syntaxhighlight lang="java" style="margin-left: 4em"> |
Revision as of 11:15, 6 April 2021
Heater stub
This stub code realizes an interface to an oven and a dummy implementation for the example code that can be executed without any hardware.
The heater interface defines common interface functions to control the oven.
/** * The heater enables controlling of the oven */ public interface IHeater { public void activate(); public void deactivate(); public boolean isActive(); }
The heater stub is used during the example.
Heater Code
/** * Simple heater with two states: activated or deactivated * */ public class Heater implments IHeater { private boolean isActive = false; public void activate() { if (!isActive) { System.out.println("Heater: activated"); isActive = true; } } public void deactivate() { if (isActive) { System.out.println("Heater: deactivated"); isActive = false; } } public boolean isActive() { return isActive; } }