Created
February 21, 2017 05:02
-
-
Save naivedeveloper95/ec11364b55798c3c363c86e595147998 to your computer and use it in GitHub Desktop.
example for Composition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SatyamCorp.company; | |
/** | |
* Created by SatyamCorp on 21-Feb-17. | |
*/ | |
public class Case { | |
private String Model; | |
private String Manufacturer; | |
private String PowerSupply; | |
private Dimension dimensions; | |
public Case(String model, String manufacturer, String powerSupply, Dimension dimensions) { | |
Model = model; | |
Manufacturer = manufacturer; | |
PowerSupply = powerSupply; | |
this.dimensions = dimensions; | |
} | |
public void pressPowerButton(){ | |
System.out.println("power Button pressed."); | |
} | |
public String getModel() { | |
return Model; | |
} | |
public String getManufacturer() { | |
return Manufacturer; | |
} | |
public String getPowerSupply() { | |
return PowerSupply; | |
} | |
public Dimension getDimensions() { | |
return dimensions; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SatyamCorp.company; | |
/** | |
* Created by SatyamCorp on 21-Feb-17. | |
*/ | |
public class Dimension { | |
private int width; | |
private int height; | |
private int depth; | |
public Dimension(int width, int height, int depth) { | |
this.width = width; | |
this.height = height; | |
this.depth = depth; | |
} | |
public int getWidth() { | |
return width; | |
} | |
public int getHeight() { | |
return height; | |
} | |
public int getDepth() { | |
return depth; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SatyamCorp.company; | |
public class Main { | |
public static void main(String[] args) { | |
// write your code here | |
Dimension dimension = new Dimension(20,40,50); | |
Case theCase = new Case("hp450","HP","240Watt",dimension); | |
Monitor theMonitor = new Monitor("LedPlasma_27","LG",27,new Resolution(1920,1080)); | |
MotherBoard motherBoard = new MotherBoard("Quick_50","Intel",4,2,"v3.0"); | |
PC thePC = new PC(theCase,theMonitor,motherBoard); | |
thePC.getTheMonitor().drawPixelAt(1500,2000,"red"); | |
thePC.getMotherBoard().LoadProgram("Windows 1.0"); | |
thePC.getTheCase().pressPowerButton(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SatyamCorp.company; | |
/** | |
* Created by SatyamCorp on 21-Feb-17. | |
*/ | |
public class Monitor { | |
private String Model; | |
private String ManufacturerName; | |
private int Size; | |
private Resolution NativeResolution; | |
public Monitor(String model, String manufacturerName, int size, Resolution nativeResolution) { | |
Model = model; | |
ManufacturerName = manufacturerName; | |
Size = size; | |
NativeResolution = nativeResolution; | |
} | |
public void drawPixelAt(int x, int y , String color){ | |
System.out.println("the pixel is drawn at " + x + " and at "+ y + " and the color is " + color ); | |
} | |
public String getModel() { | |
return Model; | |
} | |
public String getManufacturerName() { | |
return ManufacturerName; | |
} | |
public int getSize() { | |
return Size; | |
} | |
public Resolution getNativeResolution() { | |
return NativeResolution; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SatyamCorp.company; | |
/** | |
* Created by SatyamCorp on 19-Feb-17. | |
*/ | |
public class MotherBoard { | |
private String model; | |
private String ManufacturerName; | |
private int RamSlots; | |
private int CardSlots; | |
private String Bios; | |
public MotherBoard(String model, String manufacturerName, int ramSlots, int cardSlots, String bios) { | |
this.model = model; | |
ManufacturerName = manufacturerName; | |
RamSlots = ramSlots; | |
CardSlots = cardSlots; | |
Bios = bios; | |
} | |
public void LoadProgram(String ProgramName){ | |
System.out.println("Program " +ProgramName+ " is loading..!"); | |
} | |
public String getModel() { | |
return model; | |
} | |
public String getManufacturerName() { | |
return ManufacturerName; | |
} | |
public int getRamSlots() { | |
return RamSlots; | |
} | |
public int getCardSlots() { | |
return CardSlots; | |
} | |
public String getBios() { | |
return Bios; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SatyamCorp.company; | |
/** | |
* Created by SatyamCorp on 21-Feb-17. | |
*/ | |
public class PC { | |
private Case theCase; | |
private Monitor theMonitor; | |
private MotherBoard motherBoard; | |
public PC(Case theCase, Monitor theMonitor, MotherBoard motherBoard) { | |
this.theCase = theCase; | |
this.theMonitor = theMonitor; | |
this.motherBoard = motherBoard; | |
} | |
public Case getTheCase() { | |
return theCase; | |
} | |
public Monitor getTheMonitor() { | |
return theMonitor; | |
} | |
public MotherBoard getMotherBoard() { | |
return motherBoard; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SatyamCorp.company; | |
/** | |
* Created by SatyamCorp on 21-Feb-17. | |
*/ | |
public class Resolution { | |
private int width; | |
private int height; | |
public Resolution(int width, int height) { | |
this.width = width; | |
this.height = height; | |
} | |
public int getWidth() { | |
return width; | |
} | |
public int getHeight() { | |
return height; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment