Added UpdateVariable class

This commit is contained in:
Lukasz Baldyga committed 2020-11-26 12:34:30 +00:00
1 parent 0711fcad67
commit 7a4070220d
1 file changed
+28
@@ -0,0 +1,28 @@
namespace Advanced_Software_Engineering.Verbs.Value {
public class UpdateVariable : IVerb {
protected Drawer drawer;
protected string name;
protected string value;
public UpdateVariable(Drawer drawer, string name, string value) {
this.name = name;
this.value = value;
this.drawer = drawer;
}
public UpdateVariable(Drawer drawer, string name, IValue value) {
}
public void ExecuteVerb() {
IValue variable = drawer.GetVariable(name);
string type = variable.GetOriginalType();
drawer.SetVariable(name, ValueFactory.CreateValue(value, type));
}
public string GetDescription() {
return "Updates " + name + " to " + value;
}
}
}