Updated domain. Further explanation in README

main
Philipp3107 2022-12-08 23:34:47 +01:00
parent 77dd5b19f6
commit 3a856779f3
2 changed files with 64 additions and 1 deletions

View File

@ -5,30 +5,48 @@ public class R2D2 implements Robot{
private String name;
private boolean power;
/**
* Constructor
* @param id> int
* @param name> String
*/
public R2D2(int id, String name){
this.id = id;
this.name = name;
power = false;
}
/**
* @see domain.RobotControl
*/
@Override
public int getId() {
return id;
}
/**
* @see domain.RobotControl
*/
@Override
public String getName() {
return name;
}
/**
* @see domain.RobotControl
*/
@Override
public void triggerPowerSwitch() {
if(power = false){
if(power == false){
power = true;
}else{
power = false;
}
}
/**
* @see domain.RobotControl
*/
@Override
public boolean isPowerOn() {
return power;

View File

@ -0,0 +1,45 @@
package domain;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class R2D2Test {
R2D2 Herbert;
int id = 0;
String name = "Herbert";
@BeforeEach
void setup(){
Herbert = new R2D2(id, name);
}
//Tests for basic functions
@Test
void getId() {
assertEquals(0, Herbert.getId());
}
@Test
void getName() {
assertEquals(name, Herbert.getName());
}
@Test
void triggerPowerSwitch() {
Herbert.triggerPowerSwitch();
assertTrue(Herbert.isPowerOn());
}
@Test
void isPowerOn() {
assertFalse(Herbert.isPowerOn());
Herbert.triggerPowerSwitch();
assertTrue(Herbert.isPowerOn());
}
}