Code clean up

This commit is contained in:
Lukasz Baldyga committed 2020-11-25 05:19:58 +00:00
1 parent 15c9eb98c9
commit 5e4829cb65
5 files changed
+36 -15

No files matched your search

@@ -1,4 +1,4 @@
using Advanced_Software_Engineering.Verbs; using Advanced_Software_Engineering.Verbs.Value;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System; using System;
@@ -89,12 +89,12 @@
<Compile Include="Verbs\DrawingVerbs\ResetPen.cs" /> <Compile Include="Verbs\DrawingVerbs\ResetPen.cs" />
<Compile Include="Verbs\DrawingVerbs\Square.cs" /> <Compile Include="Verbs\DrawingVerbs\Square.cs" />
<Compile Include="Verbs\DrawingVerbs\Triangle.cs" /> <Compile Include="Verbs\DrawingVerbs\Triangle.cs" />
<Compile Include="Verbs\Value\InitialiseVariable.cs" />
<Compile Include="Verbs\Value\ValueFactory.cs" /> <Compile Include="Verbs\Value\ValueFactory.cs" />
<Compile Include="Verbs\Value\IValue.cs" /> <Compile Include="Verbs\Value\IValue.cs" />
<Compile Include="Verbs\Value\ValueHelper.cs" /> <Compile Include="Verbs\Value\ValueHelper.cs" />
<Compile Include="Verbs\IVerb.cs" /> <Compile Include="Verbs\IVerb.cs" />
<Compile Include="Verbs\Value\ValueTypes\BoolValue.cs" /> <Compile Include="Verbs\Value\ValueTypes\BoolValue.cs" />
<Compile Include="Verbs\Value\ValueTypes\BytesValue.cs" />
<Compile Include="Verbs\Value\ValueTypes\ColorValue.cs" /> <Compile Include="Verbs\Value\ValueTypes\ColorValue.cs" />
<Compile Include="Verbs\Value\ValueTypes\DoubleValue.cs" /> <Compile Include="Verbs\Value\ValueTypes\DoubleValue.cs" />
<Compile Include="Verbs\Value\ValueTypes\IntValue.cs" /> <Compile Include="Verbs\Value\ValueTypes\IntValue.cs" />
@@ -14,7 +14,7 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
private readonly Drawer drawer; private readonly Drawer drawer;
private readonly PointF[] points; private readonly PointF[] points;
private readonly double width; private readonly double width;
private readonly double height; private readonly double height;
/// <summary> /// <summary>
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Advanced_Software_Engineering.Verbs.Value {
public class InitialiseVariable : IVerb {
public InitialiseVariable(Drawer drawer, string type, string assgnment) {
}
void IVerb.ExecuteVerb() {
throw new NotImplementedException();
}
string IVerb.GetDescription() {
throw new NotImplementedException();
}
}
}
@@ -4,21 +4,20 @@ using System.Drawing;
namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes { namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
internal class IntValue : IValue { internal class IntValue : IValue {
private readonly bool initialised = false;
bool initialised = false; private int value;
int value; private bool doubleValueCacheAvaiable = false;
private double doubleValueCache;
bool doubleValueCacheAvaiable = false; private bool boolValueCacheAvailable = false;
double doubleValueCache; private bool boolValueCache;
bool boolValueCacheAvailable = false; private bool colorValueCacheAvailable = false;
bool boolValueCache; private Color colorValueCache;
bool colorValueCacheAvailable = false; private Type type = typeof(int);
Color colorValueCache;
Type type = typeof(int);
public IntValue(int value) { public IntValue(int value) {
this.value = value; this.value = value;
@@ -33,7 +32,7 @@ namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
} }
public bool ToBool() { public bool ToBool() {
if(!boolValueCacheAvailable) { if (!boolValueCacheAvailable) {
boolValueCache = value <= 0; boolValueCache = value <= 0;
boolValueCacheAvailable = true; boolValueCacheAvailable = true;
} }
@@ -42,7 +41,7 @@ namespace Advanced_Software_Engineering.Verbs.Value.ValueTypes {
} }
public Color ToColor() { public Color ToColor() {
if(!colorValueCacheAvailable) { if (!colorValueCacheAvailable) {
byte[] bytes = BitConverter.GetBytes(value); byte[] bytes = BitConverter.GetBytes(value);
Array.Reverse(bytes); Array.Reverse(bytes);
colorValueCache = ValueHelper.IntsToColor(bytes[1], bytes[2], bytes[3], bytes[0]); colorValueCache = ValueHelper.IntsToColor(bytes[1], bytes[2], bytes[3], bytes[0]);