Skip to content

Commit

Permalink
Merge pull request #6 from Yura1977/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
Yura1977 authored Feb 7, 2019
2 parents e6dcf80 + f375091 commit fe24290
Show file tree
Hide file tree
Showing 16 changed files with 386 additions and 460 deletions.
154 changes: 77 additions & 77 deletions ClassBuilder/immutable/Computer.java
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;
}
}
12 changes: 0 additions & 12 deletions ClassBuilder/immutable/ComputerBuilderDirector.java

This file was deleted.

17 changes: 0 additions & 17 deletions ClassBuilder/immutable/ComputerClient.java

This file was deleted.

130 changes: 65 additions & 65 deletions ClassBuilder/patternbuilder/Laptop.java
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
}
28 changes: 14 additions & 14 deletions ClassBuilder/patternbuilder/Main.java
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());
}
}

22 changes: 0 additions & 22 deletions ClassBuilder/serialization/Circle.java

This file was deleted.

Loading

0 comments on commit fe24290

Please sign in to comment.