You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
export class StudentBuilder {
private _name: String = "";
private _age: Number = 0;
constructor(){
}
setName(name: String) {
this._name = name
return this
}
setAge(age: Number) {
this._age = age
return this
}
get name(): String {
return this._name
}
get age(): Number {
return this._age
}
build() {
return new Student(this);
}
}
==================================================
client code:
const student = new StudentBuilder().setName("vijay").setAge(29).build()
Hi,
implementation of builder pattern in TS looks like -
export class Student {
name: String;
age: Number;
}
export class StudentBuilder {
private _name: String = "";
private _age: Number = 0;
}
==================================================
client code:
const student = new StudentBuilder().setName("vijay").setAge(29).build()
======================================================
but in java it is some what different.
or there is better way to implementing it.
The text was updated successfully, but these errors were encountered: