-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Yura1977/master
merge
- Loading branch information
Showing
16 changed files
with
386 additions
and
460 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,77 @@ | ||
package immutable; | ||
|
||
public final class Computer { | ||
|
||
//required parameters | ||
private final String ram; | ||
private final String hdd; | ||
private final String cpu; | ||
|
||
//optional parameters | ||
private boolean isGraphicsCardEnabled; | ||
private boolean isBluetoothEnabled; | ||
|
||
private Computer(Builder builder) { | ||
this.hdd = builder.hdd; | ||
this.cpu = builder.cpu; | ||
this.ram = builder.ram; | ||
this.isBluetoothEnabled = builder.isBluetoothEnabled; | ||
this.isGraphicsCardEnabled = builder.isGraphicsCardEnabled; | ||
} | ||
|
||
public String getRam() { | ||
return ram; | ||
} | ||
|
||
public String getHdd() { | ||
return hdd; | ||
} | ||
|
||
public String getCpu() { | ||
return cpu; | ||
} | ||
|
||
public boolean isGraphicsCardEnabled() { | ||
return isGraphicsCardEnabled; | ||
} | ||
|
||
public boolean isBluetoothEnabled() { | ||
return isBluetoothEnabled; | ||
} | ||
|
||
public static class Builder { | ||
//required parameters | ||
private String ram; | ||
private String hdd; | ||
private String cpu; | ||
|
||
//optional parameters | ||
private boolean isGraphicsCardEnabled; | ||
private boolean isBluetoothEnabled; | ||
|
||
public Builder(String ram, String hdd, String cpu) { | ||
this.ram = ram; | ||
this.hdd = hdd; | ||
this.cpu = cpu; | ||
} | ||
|
||
public Builder setGraphicsCardEnabled(boolean isGraphicsCardEnabled) { | ||
this.isGraphicsCardEnabled = isGraphicsCardEnabled; | ||
return this; | ||
} | ||
|
||
public Builder setBluetoothEnabled(boolean isBluetoothEnabled) { | ||
this.isBluetoothEnabled = isBluetoothEnabled; | ||
return this; | ||
} | ||
|
||
public Computer build() { | ||
return new Computer(this); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "HardDisc: " + "\"" + hdd + "\"" + " /ram: " + ram + " /cpu: " + cpu; | ||
} | ||
} | ||
package immutable; | ||
|
||
public final class Computer { | ||
|
||
//required parameters | ||
private final String ram; | ||
private final String hdd; | ||
private final String cpu; | ||
|
||
//optional parameters | ||
private boolean isGraphicsCardEnabled; | ||
private boolean isBluetoothEnabled; | ||
|
||
private Computer(Builder builder) { | ||
this.hdd = builder.hdd; | ||
this.cpu = builder.cpu; | ||
this.ram = builder.ram; | ||
this.isBluetoothEnabled = builder.isBluetoothEnabled; | ||
this.isGraphicsCardEnabled = builder.isGraphicsCardEnabled; | ||
} | ||
|
||
public String getRam() { | ||
return ram; | ||
} | ||
|
||
public String getHdd() { | ||
return hdd; | ||
} | ||
|
||
public String getCpu() { | ||
return cpu; | ||
} | ||
|
||
public boolean isGraphicsCardEnabled() { | ||
return isGraphicsCardEnabled; | ||
} | ||
|
||
public boolean isBluetoothEnabled() { | ||
return isBluetoothEnabled; | ||
} | ||
|
||
public static class Builder { | ||
//required parameters | ||
private String ram; | ||
private String hdd; | ||
private String cpu; | ||
|
||
//optional parameters | ||
private boolean isGraphicsCardEnabled; | ||
private boolean isBluetoothEnabled; | ||
|
||
public Builder(String ram, String hdd, String cpu) { | ||
this.ram = ram; | ||
this.hdd = hdd; | ||
this.cpu = cpu; | ||
} | ||
|
||
public Builder setGraphicsCardEnabled(boolean isGraphicsCardEnabled) { | ||
this.isGraphicsCardEnabled = isGraphicsCardEnabled; | ||
return this; | ||
} | ||
|
||
public Builder setBluetoothEnabled(boolean isBluetoothEnabled) { | ||
this.isBluetoothEnabled = isBluetoothEnabled; | ||
return this; | ||
} | ||
|
||
public Computer build() { | ||
return new Computer(this); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "HardDisc: " + "\"" + hdd + "\"" + " /ram: " + ram + " /cpu: " + cpu; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,65 @@ | ||
package patternbuilder; | ||
|
||
public class Laptop { | ||
private Processor processor; | ||
private OS os; | ||
private int ram; | ||
private int hdd; | ||
private boolean touchDisplay; | ||
|
||
public Laptop setProcessor(Processor processor) { | ||
this.processor = processor; | ||
return this; | ||
} | ||
|
||
public Laptop setRam(int ram) { | ||
this.ram = ram; | ||
return this; | ||
} | ||
|
||
public Laptop setHdd(int hdd) { | ||
this.hdd = hdd; | ||
return this; | ||
} | ||
|
||
public Laptop setTouchDisplay(boolean touchDisplay) { | ||
this.touchDisplay = touchDisplay; | ||
this.os = OS.Windows_Const; //becouse it support such dsisplays | ||
return this; | ||
} | ||
|
||
public Processor getProcessor() { | ||
return processor; | ||
} | ||
|
||
public OS getOs() { | ||
return os; | ||
} | ||
|
||
public int getRam() { | ||
return ram; | ||
} | ||
|
||
public int getHdd() { | ||
return hdd; | ||
} | ||
|
||
public boolean isTouchDisplay() { | ||
return touchDisplay; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "TouchDisplay: " + "\"" + touchDisplay + "\"" + " /HDD: " + hdd + " /RAM: " + ram + " /OS: " + os + " / Processor: " + processor; | ||
} | ||
} | ||
|
||
public enum Processor { | ||
Intel_Const, | ||
AMD_Const | ||
} | ||
|
||
public enum OS { | ||
Windows_Const, | ||
Linux_Const | ||
} | ||
package patternbuilder; | ||
|
||
public class Laptop { | ||
private Processor processor; | ||
private OS os; | ||
private int ram; | ||
private int hdd; | ||
private boolean touchDisplay; | ||
|
||
public Laptop setProcessor(Processor processor) { | ||
this.processor = processor; | ||
return this; | ||
} | ||
|
||
public Laptop setRam(int ram) { | ||
this.ram = ram; | ||
return this; | ||
} | ||
|
||
public Laptop setHdd(int hdd) { | ||
this.hdd = hdd; | ||
return this; | ||
} | ||
|
||
public Laptop setTouchDisplay(boolean touchDisplay) { | ||
this.touchDisplay = touchDisplay; | ||
this.os = OS.Windows_Const; //becouse it support such dsisplays | ||
return this; | ||
} | ||
|
||
public Processor getProcessor() { | ||
return processor; | ||
} | ||
|
||
public OS getOs() { | ||
return os; | ||
} | ||
|
||
public int getRam() { | ||
return ram; | ||
} | ||
|
||
public int getHdd() { | ||
return hdd; | ||
} | ||
|
||
public boolean isTouchDisplay() { | ||
return touchDisplay; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "TouchDisplay: " + "\"" + touchDisplay + "\"" + " /HDD: " + hdd + " /RAM: " + ram + " /OS: " + os + " / Processor: " + processor; | ||
} | ||
} | ||
|
||
public enum Processor { | ||
Intel_Const, | ||
AMD_Const | ||
} | ||
|
||
public enum OS { | ||
Windows_Const, | ||
Linux_Const | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
package patternbuilder; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
Laptop laptop = new Laptop() | ||
.setProcessor(Processor.AMD_Const) | ||
.setHdd(102400) | ||
.setRam(4 * 10240) | ||
.setTouchDisplay(false); | ||
System.out.println("Computer configuration:"); | ||
System.out.println(laptop.toString()); | ||
} | ||
} | ||
package patternbuilder; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
Laptop laptop = new Laptop() | ||
.setProcessor(Processor.AMD_Const) | ||
.setHdd(102400) | ||
.setRam(4 * 10240) | ||
.setTouchDisplay(false); | ||
System.out.println("Computer configuration:"); | ||
System.out.println(laptop.toString()); | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.