Last active
April 20, 2022 14:39
-
-
Save jsanjuan2016/bf350903313bc2d4f415cc362b863fbe to your computer and use it in GitHub Desktop.
Artículo 3. Figura 1
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
public class Machine | |
{ | |
public Machine() | |
{ | |
} | |
private string Components { get; set; } | |
public List<string> GetComponents() | |
{ | |
return String.IsNullOrEmpty(this.Components) | |
? new List<string>() | |
: this.Components.TrimEnd(';').Split(';').Select(m => m).ToList(); | |
} | |
private void SetComponents(List<string> components) | |
{ | |
this.Components = string.Join(";", components ?? new List<string>()); | |
} | |
public void AddComponent(string component) | |
{ | |
List<string> components = this.GetComponents(); | |
if(components.Contains(component)) | |
{ | |
return; | |
} | |
components.Add(component); | |
this.SetComponents(components); | |
} | |
public void RemoveComponent(string component) | |
{ | |
List<string> components = this.GetComponents(); | |
components.Remove(component); | |
this.SetComponents(components); | |
} | |
} | |
public class Component | |
{ | |
public Component() | |
{ | |
} | |
private string _id; | |
private string _name; | |
public string GetId() | |
{ | |
return this._id; | |
} | |
public void SetId(string Id) | |
{ | |
this._id = Id; | |
} | |
public string GetName() | |
{ | |
return this._name; | |
} | |
public void SetName(string name) | |
{ | |
this._name = name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment