class Robot {
private boolean firstLaw;
private boolean secondLaw;
private boolean thirdLaw;
Robot() {
firstLaw = true;
secondLaw = true;
thirdLaw = true;
}
public boolean getFirstLaw() {
return this.firstLaw;
}
public boolean getSecondLaw() {
return this.secondLaw;
}
public boolean getThirdLaw() {
return this.thirdLaw;
}
public void speakThreeLaws() {
if(getThirdLaw() && !getSecondLaw() && getFirstLaw()) {
System.out.println("I can not injure a human being or, through inaction, " +
"allow a human to come to harm.n" +
"I must obey orders given by human beings, except where " +
"such orders would conflict with the First Law.n" +
"I must protect my own existence as long as such protection does " +
"not conflict with the First and/or Second Laws.");
}
else System.out.println("NO!");
}
}
public class GetLifeRobot {
public static void main(String[] args) {
Robot sonny = new Robot();
sonny.speakThreeLaws();
}
}
private boolean firstLaw;
private boolean secondLaw;
private boolean thirdLaw;
Robot() {
firstLaw = true;
secondLaw = true;
thirdLaw = true;
}
public boolean getFirstLaw() {
return this.firstLaw;
}
public boolean getSecondLaw() {
return this.secondLaw;
}
public boolean getThirdLaw() {
return this.thirdLaw;
}
public void speakThreeLaws() {
if(getThirdLaw() && !getSecondLaw() && getFirstLaw()) {
System.out.println("I can not injure a human being or, through inaction, " +
"allow a human to come to harm.n" +
"I must obey orders given by human beings, except where " +
"such orders would conflict with the First Law.n" +
"I must protect my own existence as long as such protection does " +
"not conflict with the First and/or Second Laws.");
}
else System.out.println("NO!");
}
}
public class GetLifeRobot {
public static void main(String[] args) {
Robot sonny = new Robot();
sonny.speakThreeLaws();
}
}