-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathComplexResume.cs
47 lines (38 loc) · 1.17 KB
/
ComplexResume.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
namespace PrototypePattern;
internal class WorkExperience : ICloneable
{
public string TimePeriod { get; set; }
public string Company { get; set; }
public object Clone() => MemberwiseClone();
}
/// <summary>
/// Deep Copy
/// </summary>
internal class ComplexResume : ICloneable
{
private readonly WorkExperience _workExperience;
private string _name;
private string _email;
public ComplexResume() => _workExperience = new WorkExperience();
private ComplexResume(WorkExperience workExperience) => _workExperience = (WorkExperience)workExperience.Clone();
public void SetPersonalInfo(string name, string email)
{
_name = name;
_email = email;
}
public void SetWorkExperience(string comapny, string timePeriod)
{
_workExperience.Company = comapny;
_workExperience.TimePeriod = timePeriod;
}
public void Show()
{
Console.WriteLine($"{_name} {_email}");
Console.WriteLine($"Work Experience: {_workExperience.Company} {_workExperience.TimePeriod}");
}
public object Clone() => new ComplexResume(_workExperience)
{
_name = _name,
_email = _email
};
}