To do: Look at the following UML diagram. Create a Java program that does not ru
ID: 3707382 • Letter: T
Question
To do: Look at the following UML diagram. Create a Java program that does not run named Robot. In the program, put the six types (“type” in Java is defined as classes plus interfaces) and write the appropriate methods (either abstract or stub – they do not need a body). Since the program is named Robot.java, only the Robot class (or interface – which ever you choose for it) can be public. The rest can use the default access modifier.
IMPORTANT NOTE I'm suppose to Write a program named Robot that has the six types in the UML i'm not suppost to do these as seperate files
Explanation / Answer
The Code:
interface Toy{
public void play();
}
interface BatteryToy extends Toy{
public void replaceBattery();
}
interface Moveable{
public void moveArms();
public void walk();
}
public class Robot implements BatteryToy,Moveable{
public void play()
{}
public void replaceBattery()
{}
public void moveArms(){}
public void walk(){}
}
class RoboRaptor extends Robot{
}
class RoboSapien extends Robot{
}
P.S: Please give a thumbs up if you like the answer, and also give us feedbacks so that we can improve our answers.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.