Advertisement
KyMuC

Application template

Sep 17th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.00 KB | None | 0 0
  1. public class Program {
  2.     private String name;
  3.     private String operatingSystem = "Windows 10";
  4.    
  5.     public String getName() {
  6.         return name;
  7.     }
  8.    
  9.     public void setName(String name) {
  10.         this.name = name;
  11.     }
  12.    
  13.     public String getOperatingSystem() {
  14.         return operatingSystem;
  15.     }
  16.    
  17.     public void setOperatingSystem(String operatingSystem) {
  18.         this.operatingSystem = operatingSystem;
  19.     }
  20.    
  21.     public static void main(String[] args) {
  22.         Application app = new Application(
  23.                  new UserInterface(
  24.                          new UserControl[] {
  25.                              new UserControl("Button"),
  26.                              new UserControl()
  27.                          }
  28.                      )
  29.             );
  30.         app.present();
  31.     }
  32.    
  33.     void run() {
  34.         main(new String[0]);
  35.     }
  36. }
  37.  
  38. class Application extends Program {
  39.     private UserInterface userInterface;
  40.    
  41.     Application(UserInterface userInterface) {
  42.         this.userInterface = userInterface;
  43.     }
  44.    
  45.     void present() {
  46.         for(UserControl control: userInterface.getUserControls()) {
  47.             control.click();
  48.         }
  49.     }
  50. }
  51.  
  52. class UserInterface {
  53.     private UserControl[] userControls;
  54.    
  55.     public UserControl[] getUserControls() {
  56.         return userControls;
  57.     }
  58.    
  59.     public void setUserControls(UserControl[] userControls) {
  60.         this.userControls = userControls;
  61.     }
  62.    
  63.     UserInterface(UserControl[] userControls) {
  64.         this.userControls = userControls;
  65.     }
  66. }
  67.  
  68. class UserControl {
  69.     private String specification;
  70.    
  71.     UserControl(String specification) {
  72.         this.specification = specification;
  73.     }
  74.    
  75.     UserControl(){}
  76.    
  77.     public String getSpecification() {
  78.         return specification;
  79.     }
  80.    
  81.     public void click() {
  82.         System.out.println((specification != null ? specification + " has " : "I have ") + "been clicked!");
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement