Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Program {
- private String name;
- private String operatingSystem = "Windows 10";
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getOperatingSystem() {
- return operatingSystem;
- }
- public void setOperatingSystem(String operatingSystem) {
- this.operatingSystem = operatingSystem;
- }
- public static void main(String[] args) {
- Application app = new Application(
- new UserInterface(
- new UserControl[] {
- new UserControl("Button"),
- new UserControl()
- }
- )
- );
- app.present();
- }
- void run() {
- main(new String[0]);
- }
- }
- class Application extends Program {
- private UserInterface userInterface;
- Application(UserInterface userInterface) {
- this.userInterface = userInterface;
- }
- void present() {
- for(UserControl control: userInterface.getUserControls()) {
- control.click();
- }
- }
- }
- class UserInterface {
- private UserControl[] userControls;
- public UserControl[] getUserControls() {
- return userControls;
- }
- public void setUserControls(UserControl[] userControls) {
- this.userControls = userControls;
- }
- UserInterface(UserControl[] userControls) {
- this.userControls = userControls;
- }
- }
- class UserControl {
- private String specification;
- UserControl(String specification) {
- this.specification = specification;
- }
- UserControl(){}
- public String getSpecification() {
- return specification;
- }
- public void click() {
- System.out.println((specification != null ? specification + " has " : "I have ") + "been clicked!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement