diff --git a/158.326 Software Architecture.sln b/158.326 Software Architecture.sln
index 28bd4bd..de24ede 100644
--- a/158.326 Software Architecture.sln
+++ b/158.326 Software Architecture.sln
@@ -3,7 +3,73 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31515.178
MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "158326 Week 7 Singletons", "158326 Week 7 Singletons\158326 Week 7 Singletons.csproj", "{DDB32161-79F3-4CCF-9CCC-44CCD562B15E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tutorial 1", "Tutorial 1\Tutorial 1.csproj", "{FA8A573C-5F3A-4C27-ACB6-FC62586222AE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tutorial 2", "Tutorial 2\Tutorial 2.csproj", "{CB99F53C-9D42-44F6-B0E7-8673BCA697D2}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tutorial 3", "Tutorial 3\Tutorial 3.csproj", "{62AC24E6-5C4F-414C-AEAA-9406B825FFB8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DuckModel", "DuckModel\DuckModel.csproj", "{3085BE3E-81C7-48A4-B62A-80E8BA453DAC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppLogic", "AppLogic\AppLogic.csproj", "{F3A4E792-4405-45A5-953D-93E3618E3E46}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VTNZ_Immutable", "VTNZ_Immutable\VTNZ_Immutable.csproj", "{6665E064-A51F-4E18-9333-157F41D29152}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tutorial 4", "Tutorial 4\Tutorial 4.csproj", "{B55A6B30-1116-411A-ADEE-9E5D066F482C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tutorial 5", "Tutorial 5\Tutorial 5.csproj", "{7256BBB8-354F-467C-8377-F01C4CAE956E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tutorial 6", "Tutorial 6\Tutorial 6.csproj", "{00702453-3AD5-4822-A38C-2859B52C3E4C}"
+EndProject
Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {DDB32161-79F3-4CCF-9CCC-44CCD562B15E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DDB32161-79F3-4CCF-9CCC-44CCD562B15E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DDB32161-79F3-4CCF-9CCC-44CCD562B15E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DDB32161-79F3-4CCF-9CCC-44CCD562B15E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FA8A573C-5F3A-4C27-ACB6-FC62586222AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FA8A573C-5F3A-4C27-ACB6-FC62586222AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FA8A573C-5F3A-4C27-ACB6-FC62586222AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FA8A573C-5F3A-4C27-ACB6-FC62586222AE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CB99F53C-9D42-44F6-B0E7-8673BCA697D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CB99F53C-9D42-44F6-B0E7-8673BCA697D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CB99F53C-9D42-44F6-B0E7-8673BCA697D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CB99F53C-9D42-44F6-B0E7-8673BCA697D2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {62AC24E6-5C4F-414C-AEAA-9406B825FFB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {62AC24E6-5C4F-414C-AEAA-9406B825FFB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {62AC24E6-5C4F-414C-AEAA-9406B825FFB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {62AC24E6-5C4F-414C-AEAA-9406B825FFB8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3085BE3E-81C7-48A4-B62A-80E8BA453DAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3085BE3E-81C7-48A4-B62A-80E8BA453DAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3085BE3E-81C7-48A4-B62A-80E8BA453DAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3085BE3E-81C7-48A4-B62A-80E8BA453DAC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F3A4E792-4405-45A5-953D-93E3618E3E46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F3A4E792-4405-45A5-953D-93E3618E3E46}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F3A4E792-4405-45A5-953D-93E3618E3E46}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F3A4E792-4405-45A5-953D-93E3618E3E46}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6665E064-A51F-4E18-9333-157F41D29152}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6665E064-A51F-4E18-9333-157F41D29152}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6665E064-A51F-4E18-9333-157F41D29152}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6665E064-A51F-4E18-9333-157F41D29152}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B55A6B30-1116-411A-ADEE-9E5D066F482C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B55A6B30-1116-411A-ADEE-9E5D066F482C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B55A6B30-1116-411A-ADEE-9E5D066F482C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B55A6B30-1116-411A-ADEE-9E5D066F482C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7256BBB8-354F-467C-8377-F01C4CAE956E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7256BBB8-354F-467C-8377-F01C4CAE956E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7256BBB8-354F-467C-8377-F01C4CAE956E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7256BBB8-354F-467C-8377-F01C4CAE956E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {00702453-3AD5-4822-A38C-2859B52C3E4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {00702453-3AD5-4822-A38C-2859B52C3E4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {00702453-3AD5-4822-A38C-2859B52C3E4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {00702453-3AD5-4822-A38C-2859B52C3E4C}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
diff --git a/AppLogic/AppLogic.csproj b/AppLogic/AppLogic.csproj
new file mode 100644
index 0000000..bdc20a4
--- /dev/null
+++ b/AppLogic/AppLogic.csproj
@@ -0,0 +1,57 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {F3A4E792-4405-45A5-953D-93E3618E3E46}
+ Library
+ Properties
+ AppLogic
+ AppLogic
+ v4.7.2
+ 512
+ true
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {6665e064-a51f-4e18-9333-157f41d29152}
+ VTNZ_Immutable
+
+
+
+
\ No newline at end of file
diff --git a/AppLogic/CompetitorStoreFront.cs b/AppLogic/CompetitorStoreFront.cs
new file mode 100644
index 0000000..337df7b
--- /dev/null
+++ b/AppLogic/CompetitorStoreFront.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AppLogic
+{
+ public class CompetitorStoreFront : IStoreFront
+ {
+ string _storefrontName;
+ string _storefrontAddress;
+ string _storefrontPhoneNumber;
+ string[] _storefrontOpenDays;
+ TimeSpan[] _storefrontTimeOpen;
+
+ List _storeProducts;
+
+ public string GetName => _storefrontName;
+
+ public string GetAddress => _storefrontAddress;
+
+ public string[] GetOpenDays => _storefrontOpenDays;
+
+ public TimeSpan[] GetOpenTime => _storefrontTimeOpen;
+
+ public string GetPhoneNumber => _storefrontPhoneNumber;
+
+ public List GetProducts => _storeProducts;
+
+
+ public CompetitorStoreFront(string name, string location, string phone, string[] workingDays, TimeSpan[] dayLengths)
+ {
+ _storefrontName = name;
+ _storefrontAddress = location;
+ _storefrontPhoneNumber = phone;
+ _storefrontOpenDays = workingDays;
+ _storefrontTimeOpen = dayLengths;
+
+ _storeProducts = new List();
+ }
+ public override string ToString()
+ {
+ return _storefrontName;
+ }
+
+ }
+}
diff --git a/AppLogic/IProduct.cs b/AppLogic/IProduct.cs
new file mode 100644
index 0000000..885ba7e
--- /dev/null
+++ b/AppLogic/IProduct.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AppLogic
+{
+ public interface IProduct
+ {
+ string Name { get; }
+ decimal Value { get; }
+ // Extra definitions here
+
+
+ }
+}
diff --git a/AppLogic/IStoreFront.cs b/AppLogic/IStoreFront.cs
new file mode 100644
index 0000000..04f7420
--- /dev/null
+++ b/AppLogic/IStoreFront.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AppLogic
+{
+ public interface IStoreFront
+ {
+
+ string GetName { get; }
+ string GetAddress { get; }
+ string GetPhoneNumber { get; }
+ string[] GetOpenDays { get; }
+ TimeSpan[] GetOpenTime { get; }
+
+ List GetProducts { get; }
+ }
+}
diff --git a/AppLogic/Properties/AssemblyInfo.cs b/AppLogic/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..e81aa89
--- /dev/null
+++ b/AppLogic/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("AppLogic")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AppLogic")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f3a4e792-4405-45a5-953d-93e3618e3e46")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/AppLogic/VTNZ_StoreFront.cs b/AppLogic/VTNZ_StoreFront.cs
new file mode 100644
index 0000000..254f363
--- /dev/null
+++ b/AppLogic/VTNZ_StoreFront.cs
@@ -0,0 +1,121 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AppLogic
+{
+ public class VTNZ_StoreFront : IStoreFront
+ {
+ string _storefrontName;
+ string _storefrontAddress;
+ string _storefrontPhoneNumber;
+ string[] _storefrontOpenDays;
+ TimeSpan[] _storefrontTimeOpen;
+
+ List _storeProducts;
+
+ public string GetName => _storefrontName;
+
+ public string GetAddress => _storefrontAddress;
+
+ public string[] GetOpenDays => _storefrontOpenDays;
+
+ public TimeSpan[] GetOpenTime => _storefrontTimeOpen;
+
+ public string GetPhoneNumber => _storefrontPhoneNumber;
+
+ public List GetProducts => _storeProducts;
+
+ public VTNZ_StoreFront(string name, string location, string phone, string[] workingDays, TimeSpan[] dayLengths)
+ {
+ _storefrontName = name;
+ _storefrontAddress = location;
+ _storefrontPhoneNumber = phone;
+ _storefrontOpenDays = workingDays;
+ _storefrontTimeOpen = dayLengths;
+ _storeProducts = new List
+ {
+ new WofInspectionWrap(new VTNZ_Immutable.General("Wof", 25)),
+ new ModifiedInspectionWrap(new VTNZ_Immutable.ModifiedInspection()),
+ new PrePurchaseInspectionWrap(new VTNZ_Immutable.PrePurchaseInspection()),
+ new CoFInspectionWrap(new VTNZ_Immutable.CoFInspection())
+ };
+ }
+ public override string ToString()
+ {
+ return _storefrontName;
+ }
+
+ }
+
+ public class WofInspectionWrap : IProduct
+ {
+ VTNZ_Immutable.General _inspection;
+ public string Name => _inspection.Name;
+
+ public decimal Value => _inspection.Value;
+
+ public WofInspectionWrap(VTNZ_Immutable.General inspection)
+ {
+ this._inspection = inspection;
+ }
+
+ public override string ToString()
+ {
+ return Name + (Name.Length < 27 ? new string(' ', 27 - Name.Length) : "") + Value;
+ }
+ }
+
+ public class ModifiedInspectionWrap : IProduct
+ {
+ VTNZ_Immutable.ModifiedInspection _inspection;
+ public string Name => _inspection.InspectionType;
+
+ public decimal Value => _inspection.Value;
+
+ public ModifiedInspectionWrap(VTNZ_Immutable.ModifiedInspection inspection)
+ {
+ this._inspection = inspection;
+ }
+ public override string ToString()
+ {
+ return Name + (Name.Length < 27 ? new string(' ', 27 - Name.Length) : "")+ Value;
+ }
+ }
+
+ public class PrePurchaseInspectionWrap : IProduct
+ {
+ VTNZ_Immutable.PrePurchaseInspection _inspection;
+ public string Name => _inspection.Name;
+
+ public decimal Value => _inspection.Value;
+
+ public PrePurchaseInspectionWrap(VTNZ_Immutable.PrePurchaseInspection inspection)
+ {
+ this._inspection = inspection;
+ }
+ public override string ToString()
+ {
+ return Name + (Name.Length < 27 ? new string(' ', 27 - Name.Length) : "")+ Value;
+ }
+ }
+
+ public class CoFInspectionWrap : IProduct
+ {
+ VTNZ_Immutable.CoFInspection _inspection;
+ public string Name => _inspection.Name;
+
+ public decimal Value => _inspection.Value;
+
+ public CoFInspectionWrap(VTNZ_Immutable.CoFInspection inspection)
+ {
+ this._inspection = inspection;
+ }
+ public override string ToString()
+ {
+ return Name + (Name.Length < 27 ? new string(' ', 27 - Name.Length) : "") + Value;
+ }
+ }
+}
diff --git a/DuckModel/DecoyDuck.cs b/DuckModel/DecoyDuck.cs
new file mode 100644
index 0000000..4c8c336
--- /dev/null
+++ b/DuckModel/DecoyDuck.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DuckModel
+{
+ class DecoyDuck : DuckBehaviour
+ {
+ public override void Display()
+ {
+ Console.WriteLine("drew a decoy duck");
+ }
+
+ DecoyDuck()
+ {
+ base.SetFlyBehaviour(new NoFly());
+ base.SetQuackBehaviour(new MuteQuack());
+ }
+ }
+}
diff --git a/DuckModel/DuckBehaviours.cs b/DuckModel/DuckBehaviours.cs
new file mode 100644
index 0000000..3002d50
--- /dev/null
+++ b/DuckModel/DuckBehaviours.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DuckModel
+{
+ public interface IFlyBehaviour
+ {
+ void Fly();
+ }
+
+ public interface IQuackBehaviour
+ {
+ void Quack();
+ }
+ public abstract class DuckBehaviour
+ {
+ IFlyBehaviour _flyBehaviour;
+ IQuackBehaviour _quackBehaviour;
+
+ public void Swim()
+ {
+ Console.WriteLine("The duck swims");
+ }
+
+ public abstract void Display();
+
+ void PerformQuack()
+ {
+ _quackBehaviour.Quack();
+ }
+
+ void PerformFly()
+ {
+ _flyBehaviour.Fly();
+ }
+
+ protected void SetFlyBehaviour(IFlyBehaviour flyBehaviour)
+ {
+ _flyBehaviour = flyBehaviour;
+ }
+
+ protected void SetQuackBehaviour(IQuackBehaviour newBehaviour)
+ {
+ _quackBehaviour = newBehaviour;
+ }
+ }
+
+ class Quack : IQuackBehaviour
+ {
+ void IQuackBehaviour.Quack()
+ {
+ Console.WriteLine("The duck quacks");
+ }
+ }
+
+ class Squeak : IQuackBehaviour
+ {
+ void IQuackBehaviour.Quack()
+ {
+ Console.WriteLine("The duck squeaks");
+ }
+ }
+
+ class MuteQuack : IQuackBehaviour
+ {
+ void IQuackBehaviour.Quack()
+ {
+ Console.WriteLine("The duck makes no sound");
+ }
+ }
+
+ class FlyWithWings : IFlyBehaviour
+ {
+ public void Fly()
+ {
+ Console.WriteLine("The duck flies away");
+ }
+ }
+
+ class NoFly : IFlyBehaviour
+ {
+ public void Fly()
+ {
+ Console.WriteLine("The duck cannot fly");
+ }
+ }
+}
diff --git a/DuckModel/DuckModel.csproj b/DuckModel/DuckModel.csproj
new file mode 100644
index 0000000..4f499eb
--- /dev/null
+++ b/DuckModel/DuckModel.csproj
@@ -0,0 +1,52 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {3085BE3E-81C7-48A4-B62A-80E8BA453DAC}
+ Library
+ Properties
+ DuckModel
+ DuckModel
+ v4.5
+ 512
+ true
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DuckModel/MallardDuck.cs b/DuckModel/MallardDuck.cs
new file mode 100644
index 0000000..25d4ae1
--- /dev/null
+++ b/DuckModel/MallardDuck.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DuckModel
+{
+ class MallardDuck : DuckBehaviour
+ {
+ public override void Display()
+ {
+ Console.WriteLine("drew a Mallard duck");
+ }
+
+ MallardDuck()
+ {
+ base.SetFlyBehaviour(new FlyWithWings());
+ base.SetQuackBehaviour(new Quack());
+ }
+ }
+}
diff --git a/DuckModel/Properties/AssemblyInfo.cs b/DuckModel/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..6792888
--- /dev/null
+++ b/DuckModel/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("DuckModel")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("DuckModel")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("3085be3e-81c7-48a4-b62a-80e8ba453dac")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/DuckModel/RedheadDuck.cs b/DuckModel/RedheadDuck.cs
new file mode 100644
index 0000000..d8de35b
--- /dev/null
+++ b/DuckModel/RedheadDuck.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DuckModel
+{
+ class RedheadDuck : DuckBehaviour
+ {
+ public override void Display()
+ {
+ Console.WriteLine("drew a Redhead duck");
+ }
+
+ RedheadDuck()
+ {
+ base.SetFlyBehaviour(new FlyWithWings());
+ base.SetQuackBehaviour(new Quack());
+ }
+ }
+}
diff --git a/DuckModel/RubberDucky.cs b/DuckModel/RubberDucky.cs
new file mode 100644
index 0000000..a6918c9
--- /dev/null
+++ b/DuckModel/RubberDucky.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DuckModel
+{
+ class RubberDucky : DuckBehaviour
+ {
+ public override void Display()
+ {
+ Console.WriteLine("drew a Rubber ducky");
+ }
+
+ RubberDucky()
+ {
+ base.SetFlyBehaviour(new NoFly());
+ base.SetQuackBehaviour(new Squeak());
+ }
+ }
+}
diff --git a/Tutorial 1/App.config b/Tutorial 1/App.config
new file mode 100644
index 0000000..d1428ad
--- /dev/null
+++ b/Tutorial 1/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/Tutorial 1/CustomerParking.cs b/Tutorial 1/CustomerParking.cs
new file mode 100644
index 0000000..c80e086
--- /dev/null
+++ b/Tutorial 1/CustomerParking.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lab1
+{
+ class CustomerParking : ParkingType
+ {
+ public override decimal Calculate(decimal hours)
+ {
+ hours = Math.Ceiling(hours);
+ if (hours < 0)
+ {
+ throw new ParkingException("Parked for no or negative hours");
+ }
+ else if (hours > 24)
+ {
+ throw new ParkingException("Vehicle was parked for too long");
+ }
+ decimal value = hours * ParkingRate;
+ return value;
+ }
+ }
+}
diff --git a/Tutorial 1/Form1.Designer.cs b/Tutorial 1/Form1.Designer.cs
new file mode 100644
index 0000000..5eebab8
--- /dev/null
+++ b/Tutorial 1/Form1.Designer.cs
@@ -0,0 +1,197 @@
+
+namespace Lab1
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.radioButton2 = new System.Windows.Forms.RadioButton();
+ this.radioButton1 = new System.Windows.Forms.RadioButton();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.WarningLabel = new System.Windows.Forms.Label();
+ this.totalValue = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.hoursEntered = new System.Windows.Forms.TextBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label1 = new System.Windows.Forms.Label();
+ this.groupBox1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.radioButton2);
+ this.groupBox1.Controls.Add(this.radioButton1);
+ this.groupBox1.Location = new System.Drawing.Point(264, 12);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(197, 119);
+ this.groupBox1.TabIndex = 0;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Customer Type";
+ //
+ // radioButton2
+ //
+ this.radioButton2.AutoSize = true;
+ this.radioButton2.Location = new System.Drawing.Point(7, 66);
+ this.radioButton2.Name = "radioButton2";
+ this.radioButton2.Size = new System.Drawing.Size(87, 29);
+ this.radioButton2.TabIndex = 1;
+ this.radioButton2.TabStop = true;
+ this.radioButton2.Text = "Staff";
+ this.radioButton2.UseVisualStyleBackColor = true;
+ this.radioButton2.CheckedChanged += new System.EventHandler(this.CustomerTypeChange_CheckedChanged);
+ //
+ // radioButton1
+ //
+ this.radioButton1.AutoSize = true;
+ this.radioButton1.Location = new System.Drawing.Point(7, 31);
+ this.radioButton1.Name = "radioButton1";
+ this.radioButton1.Size = new System.Drawing.Size(135, 29);
+ this.radioButton1.TabIndex = 0;
+ this.radioButton1.TabStop = true;
+ this.radioButton1.Text = "Customer";
+ this.radioButton1.UseVisualStyleBackColor = true;
+ this.radioButton1.CheckedChanged += new System.EventHandler(this.CustomerTypeChange_CheckedChanged);
+ //
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.WarningLabel);
+ this.groupBox2.Controls.Add(this.totalValue);
+ this.groupBox2.Controls.Add(this.label4);
+ this.groupBox2.Controls.Add(this.hoursEntered);
+ this.groupBox2.Controls.Add(this.label3);
+ this.groupBox2.Controls.Add(this.label2);
+ this.groupBox2.Controls.Add(this.label1);
+ this.groupBox2.Location = new System.Drawing.Point(12, 136);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(848, 302);
+ this.groupBox2.TabIndex = 1;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Hours to park for";
+ //
+ // WarningLabel
+ //
+ this.WarningLabel.AutoSize = true;
+ this.WarningLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.875F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.WarningLabel.ForeColor = System.Drawing.Color.Maroon;
+ this.WarningLabel.Location = new System.Drawing.Point(467, 116);
+ this.WarningLabel.Name = "WarningLabel";
+ this.WarningLabel.Size = new System.Drawing.Size(313, 25);
+ this.WarningLabel.TabIndex = 6;
+ this.WarningLabel.Text = "Hours must be between 0-24";
+ this.WarningLabel.Visible = false;
+ //
+ // totalValue
+ //
+ this.totalValue.AutoSize = true;
+ this.totalValue.Location = new System.Drawing.Point(321, 153);
+ this.totalValue.Name = "totalValue";
+ this.totalValue.Size = new System.Drawing.Size(66, 25);
+ this.totalValue.TabIndex = 5;
+ this.totalValue.Text = "$0.00";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.875F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label4.Location = new System.Drawing.Point(252, 153);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(79, 25);
+ this.label4.TabIndex = 4;
+ this.label4.Text = "Total: ";
+ //
+ // hoursEntered
+ //
+ this.hoursEntered.Location = new System.Drawing.Point(291, 115);
+ this.hoursEntered.Name = "hoursEntered";
+ this.hoursEntered.Size = new System.Drawing.Size(169, 31);
+ this.hoursEntered.TabIndex = 3;
+ this.hoursEntered.TextChanged += new System.EventHandler(this.HoursEntered_TextChanged);
+ this.hoursEntered.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.HoursEntered_KeyPress);
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(247, 87);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(268, 25);
+ this.label3.TabIndex = 2;
+ this.label3.Text = "Enter the hours to park for:";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(275, 42);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(194, 25);
+ this.label2.TabIndex = 1;
+ this.label2.Text = "Maximum 24 hours";
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(275, 17);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(216, 25);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Parking is $2.00/hour";
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(874, 450);
+ this.Controls.Add(this.groupBox2);
+ this.Controls.Add(this.groupBox1);
+ this.Name = "Form1";
+ this.Text = "Calculator";
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.RadioButton radioButton1;
+ private System.Windows.Forms.RadioButton radioButton2;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.TextBox hoursEntered;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Label totalValue;
+ private System.Windows.Forms.Label WarningLabel;
+ }
+}
+
diff --git a/Tutorial 1/Form1.cs b/Tutorial 1/Form1.cs
new file mode 100644
index 0000000..6618a29
--- /dev/null
+++ b/Tutorial 1/Form1.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Lab1
+{
+ public partial class Form1 : Form
+ {
+ RadioButton selection = null;
+ ParkingType parkingType;
+
+ public Form1()
+ {
+ InitializeComponent();
+ }
+
+ private void CustomerTypeChange_CheckedChanged(object sender, EventArgs e)
+ {
+ selection = (RadioButton)sender;
+ if (selection == radioButton1) parkingType = new CustomerParking();
+ else parkingType = new StaffParking();
+ UpdateValue();
+ }
+
+ private void HoursEntered_TextChanged(object sender, EventArgs e)
+ {
+ UpdateValue();
+ }
+
+ private void UpdateValue()
+ {
+ string hoursEnteredText = hoursEntered.Text.Length > 0 ? hoursEntered.Text : "0";
+ try
+ {
+ totalValue.Text = parkingType.Calculate(Convert.ToDecimal(hoursEnteredText)).ToString("C", CultureInfo.GetCultureInfo("en-NZ"));
+ WarningLabel.Visible = false;
+ }
+ catch (ParkingException ex)
+ {
+ WarningLabel.Visible = true;
+ totalValue.Text = "$-.--";
+ }
+ }
+
+ private void HoursEntered_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) &&
+ (e.KeyChar != '.'))
+ {
+ e.Handled = true;
+ }
+
+ // only allow one decimal point
+ if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
+ {
+ e.Handled = true;
+ }
+ }
+ }
+}
diff --git a/Tutorial 1/Form1.resx b/Tutorial 1/Form1.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/Tutorial 1/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Tutorial 1/ParkingException.cs b/Tutorial 1/ParkingException.cs
new file mode 100644
index 0000000..2069bee
--- /dev/null
+++ b/Tutorial 1/ParkingException.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lab1
+{
+ class ParkingException : ApplicationException
+ {
+ public ParkingException(string message) : base(message)
+ {
+ }
+ }
+}
diff --git a/Tutorial 1/ParkingType.cs b/Tutorial 1/ParkingType.cs
new file mode 100644
index 0000000..e33a8b3
--- /dev/null
+++ b/Tutorial 1/ParkingType.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lab1
+{
+ abstract class ParkingType
+ {
+ struct test
+ {
+ decimal test2;
+ }
+ decimal _parkingRate = 2.00M;
+ public decimal ParkingRate
+ {
+ get { return _parkingRate; }
+ set { _parkingRate = value; }
+ }
+
+ abstract public decimal Calculate(decimal hours);
+
+ }
+}
diff --git a/Tutorial 1/Program.cs b/Tutorial 1/Program.cs
new file mode 100644
index 0000000..d40bcc0
--- /dev/null
+++ b/Tutorial 1/Program.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Lab1
+{
+ static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+
+
+}
diff --git a/Tutorial 1/Properties/AssemblyInfo.cs b/Tutorial 1/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..48ddfde
--- /dev/null
+++ b/Tutorial 1/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Lab1")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Lab1")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("fa8a573c-5f3a-4c27-acb6-fc62586222ae")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tutorial 1/Properties/Resources.Designer.cs b/Tutorial 1/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..f914233
--- /dev/null
+++ b/Tutorial 1/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Lab1.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Lab1.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Tutorial 1/Properties/Resources.resx b/Tutorial 1/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/Tutorial 1/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Tutorial 1/Properties/Settings.Designer.cs b/Tutorial 1/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..daa2d1e
--- /dev/null
+++ b/Tutorial 1/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Lab1.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/Tutorial 1/Properties/Settings.settings b/Tutorial 1/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/Tutorial 1/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/Tutorial 1/StaffParking.cs b/Tutorial 1/StaffParking.cs
new file mode 100644
index 0000000..1b12448
--- /dev/null
+++ b/Tutorial 1/StaffParking.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lab1
+{
+ class StaffParking : ParkingType
+ {
+ public override decimal Calculate(decimal hours)
+ {
+ hours = Math.Ceiling(hours);
+ if (hours < 0)
+ {
+ throw new ParkingException("Parked for no or negative hours");
+ }
+ else if (hours > 24)
+ {
+ throw new ParkingException("Vehicle was parked for too long");
+ }
+ decimal value = hours > 0 ? ParkingRate : 0;
+ if (hours <= 10)
+ {
+ hours = 0;
+ }
+ else
+ {
+ hours -= 10;
+ }
+ value += hours * ParkingRate;
+ return value;
+ }
+ }
+}
diff --git a/Tutorial 1/Tutorial 1.csproj b/Tutorial 1/Tutorial 1.csproj
new file mode 100644
index 0000000..0c148a0
--- /dev/null
+++ b/Tutorial 1/Tutorial 1.csproj
@@ -0,0 +1,89 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {FA8A573C-5F3A-4C27-ACB6-FC62586222AE}
+ WinExe
+ Lab1
+ Lab1
+ v4.5
+ 512
+ true
+ true
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+
+
+
+
+ Form1.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+ True
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tutorial 1/Tutorial 1.pdf b/Tutorial 1/Tutorial 1.pdf
new file mode 100644
index 0000000..0035698
--- /dev/null
+++ b/Tutorial 1/Tutorial 1.pdf
@@ -0,0 +1,55 @@
+ 158.326 Software Architecture – Semester 2
+
+Tutorial 1 – use Microsoft Visual Studio 2019
+
+Write a program (using classes) for the following scenario.
+
+A payment kiosk is used by staff and customers to pay for parking tickets.
+Parking rules are as follows:
+Staff:
+
+ 1. The parking charges for the first ten hours are $2.00.
+ 2. Further parking beyond 10 hours will incur a charge of $2.00 per hour.
+ 3. Parking time cannot exceed 24 hours. If a car is parked for more than 24 hours, it will be
+
+ towed away.
+Customer
+
+ 1. The parking charges are based per hour. Parking per hour = $ 2.00
+ 2. Parking time cannot exceed 24 hours. If a car is parked for more than 24 hours, it will be
+
+ towed away.
+
+The program should display the parking charges for each staff or customer. Charges are
+calculated based on the number of hours a car has been parked.
+
+You have to make a two-tier design:
+
+Class Design
+Identify what classes you are going to use. What will be the fields, properties and methods?
+
+ Hints:
+ 1. Useful Math functions: Math.Ceiling, Math.Abs(x), Math.Floor(x), Math.Max(x,y),
+ Math.Min(x,y)
+ If a person has parked for 3.5 hours, the kiosk will charge him for 4 hours. So, use
+ Math.Ceiling function
+ Math.Ceiling(3.5) = 4
+ 2. To display output in currency format – use ToString(“C”) (refer to
+ http://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx
+
+Reference:
+
+Pro C# 5.0 and .NET4.5 Framework
+Author: Andrew Troelsen
+ISBN: 978-1-4302-4234-5
+Edition: 6th, Publisher: Apress, E-book
+
+ Chapter 5 – Understanding Encapsulation
+ Chapter 6 – Understanding Inheritance and Polymorphism
+ Chapter 7 – Understanding Structured Exception Handling
+HINT:
+Form Design
+On selecting Customer or Staff, and clicking the “Next” button:
+The parking amount varies for customer and staff
+If parking exceeds 24 hours, an exception is thrown from a class member and caught by the form.
+
\ No newline at end of file
diff --git a/Tutorial 2/App.config b/Tutorial 2/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/Tutorial 2/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tutorial 2/ClassDiagram1.cd b/Tutorial 2/ClassDiagram1.cd
new file mode 100644
index 0000000..356d0ae
--- /dev/null
+++ b/Tutorial 2/ClassDiagram1.cd
@@ -0,0 +1,66 @@
+
+
+
+
+
+ AAAAAAAAACAAAAAAAACAAAACAAAAAAAAAAAAAAAAAAA=
+ Form1.cs
+
+
+
+
+
+ AAAAAAAAAAAAAAAAAAAAgCAAAAAAAAAAAAAAAAAAAAA=
+ ParkingKiosk.cs
+
+
+
+
+
+ AAAAAAAAAAAAAAAAAAAAgCAAAAAAAAAAAAAAAAAAAAA=
+ ParkingKiosk.cs
+
+
+
+
+
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
+ ParkingKiosk.cs
+
+
+
+
+
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAA=
+ Program.cs
+
+
+
+
+
+ AAAAAAAAAAAAAAAAAAABEAAAAQAAAAAAAAAAAAAAAIA=
+
+
+
+
+
+ AAAAAAAAAAAAAAAAAAAAIAAAAAABAAAAAAAAAAAAAAA=
+
+
+
+
+
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
+ StaffWrap.cs
+
+
+
+
+
+
+ AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAACAAAAAAA=
+ IParkingKiosk.cs
+
+
+
+
\ No newline at end of file
diff --git a/Tutorial 2/Form1.Designer.cs b/Tutorial 2/Form1.Designer.cs
new file mode 100644
index 0000000..d801abf
--- /dev/null
+++ b/Tutorial 2/Form1.Designer.cs
@@ -0,0 +1,41 @@
+
+namespace Tutorial_2
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Text = "Form1";
+ }
+
+ #endregion
+ }
+}
+
diff --git a/Tutorial 2/Form1.cs b/Tutorial 2/Form1.cs
new file mode 100644
index 0000000..af55afc
--- /dev/null
+++ b/Tutorial 2/Form1.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Tutorial_2
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Tutorial 2/IParkingKiosk.cs b/Tutorial 2/IParkingKiosk.cs
new file mode 100644
index 0000000..d7d266f
--- /dev/null
+++ b/Tutorial 2/IParkingKiosk.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tutorial_2
+{
+ interface IParkingKiosk
+ {
+ decimal HoursParked
+ {
+ get;
+ }
+
+ decimal FindParkingAmount();
+
+ }
+}
diff --git a/Tutorial 2/ParkingKiosk.cs b/Tutorial 2/ParkingKiosk.cs
new file mode 100644
index 0000000..8c13bad
--- /dev/null
+++ b/Tutorial 2/ParkingKiosk.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tutorial_2
+{
+ class GeneralParkingKiosk
+ {
+ private decimal _hoursParked;
+
+ public decimal GeneralHoursParked
+ {
+ get { return _hoursParked; }
+ set { _hoursParked = value; }
+ }
+
+ public decimal FindGeneralParkingAmount()
+ {
+ return 2.0m * _hoursParked;
+ }
+ }
+
+ class StaffParkingKiosk
+ {
+ private decimal _hoursParked;
+
+ public decimal GeneralHoursParked
+ {
+ get { return _hoursParked; }
+ set { _hoursParked = value; }
+ }
+
+ public decimal FindGeneralParkingAmount()
+ {
+ return 2.0m * _hoursParked;
+ }
+ }
+
+ class StudentParkingKiosk
+ {
+
+ }
+}
diff --git a/Tutorial 2/Program.cs b/Tutorial 2/Program.cs
new file mode 100644
index 0000000..fcf6e91
--- /dev/null
+++ b/Tutorial 2/Program.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Tutorial_2
+{
+ static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/Tutorial 2/Properties/AssemblyInfo.cs b/Tutorial 2/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f27b89e
--- /dev/null
+++ b/Tutorial 2/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tutorial 2")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tutorial 2")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("cb99f53c-9d42-44f6-b0e7-8673bca697d2")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tutorial 2/Properties/Resources.Designer.cs b/Tutorial 2/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..fb89b44
--- /dev/null
+++ b/Tutorial 2/Properties/Resources.Designer.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace Tutorial_2.Properties
+{
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tutorial_2.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Tutorial 2/Properties/Resources.resx b/Tutorial 2/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/Tutorial 2/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Tutorial 2/Properties/Settings.Designer.cs b/Tutorial 2/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..a806b41
--- /dev/null
+++ b/Tutorial 2/Properties/Settings.Designer.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace Tutorial_2.Properties
+{
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/Tutorial 2/Properties/Settings.settings b/Tutorial 2/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/Tutorial 2/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/Tutorial 2/StaffWrap.cs b/Tutorial 2/StaffWrap.cs
new file mode 100644
index 0000000..049bce8
--- /dev/null
+++ b/Tutorial 2/StaffWrap.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Tutorial_2
+{
+ public class StaffWrap : IParkingKiosk
+ {
+ StaffWrap(StaffParkingKiosk staffParkingKiosk)
+ {
+ _staffParkingKiosk = staffParkingKiosk;
+ }
+ private StaffParkingKiosk _staffParkingKiosk;
+ public decimal HoursParked => _staffParkingKiosk.GeneralHoursParked;
+
+ public decimal FindParkingAmount()
+ {
+ return _staffParkingKiosk.FindGeneralParkingAmount();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Tutorial 2/Tutorial 2.csproj b/Tutorial 2/Tutorial 2.csproj
new file mode 100644
index 0000000..c6f1a6a
--- /dev/null
+++ b/Tutorial 2/Tutorial 2.csproj
@@ -0,0 +1,84 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {CB99F53C-9D42-44F6-B0E7-8673BCA697D2}
+ WinExe
+ Tutorial_2
+ Tutorial 2
+ v4.7.2
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tutorial 2/Tutorial 2.pdf b/Tutorial 2/Tutorial 2.pdf
new file mode 100644
index 0000000..a42a040
--- /dev/null
+++ b/Tutorial 2/Tutorial 2.pdf
@@ -0,0 +1,74 @@
+ 158.326 Software Architecture – Semester 2
+ Tutorial 2
+
+Tutorial 2 (Part A) – use Visio or draw by hand on paper
+
+Draw a component diagram on one page to indicate the following scenario for a Public Library:
+The diagram should be an overview of the major components that would be needed by the library.
+It should NOT show the detail of the processes carried out by the components.
+
+Customers can check items (e.g. books/ DVDs/ magazines) via the library’s Web Browser.
+Customers should have valid library cards because the library only loans items to customers with
+valid library cards.
+Some items are loaned free, but some other items (e.g., DVDs, new books) require payment.
+If items are returned after a due date, then a fine of $2 is applied per day.
+The payment can be via cash or EFTPOS.
+
+Tutorial 2 (Part B) – Create a new project based on a modification of the Tutorial 1 Parking
+scenario:
+
+1. Define 3 classes GeneralParkingKiosk, StaffParkingKiosk and StudenParkingKiosk as
+
+follows
+
+GeneralParkingKiosk -
+
+Properties: GeneralHoursParked : Decimal
+
+Method : FindGeneralParkingAmount( ): Decimal
+
+Rule - $ 2 per hour
+
+StaffParkingKiosk -
+
+Properties: StaffHoursParked: Decimal
+
+Method : FindStaffParkingAmount( ): Decimal
+
+Rule –$ 2 for the first ten hours. For hours in excess of the ten, staff will be charged $ 2 per hour.
+
+StudentParkingKiosk - StudentHoursParked: Decimal
+Properties: FindStudentParkingAmount( ): Decimal
+Method :
+Rule - $ 1 per hour.
+
+ 1
+2. Add an interface IKiosk as follows:
+
+IParking -
+
+Properties: HoursParked: Decimal – ReadOnly
+
+Method : FindParkingAmount( ): Decimal
+
+3. Define three new classes GenKioskWrap, StaffKioskWrap and StudKioskWrap as follows
+The three classes should
+
+ a. Implement IKiosk
+ b. Encapsulate the classes defined in 1(i.e., The GenKioskWrap class encapsulates the class
+
+ GeneralParkingKiosk, the StaffKioskWrap class encapsulates StaffParkingKiosk, and so
+ on)
+
+ IKiosk
+
+ GeneralParkingKiosk GenKioskWrap
+
+4. Create an Enum called ParkType
+
+5. Form Design
+
+NOTE: Use Math.Ceiling function to convert decimals to the next highest integer
+
+ 2
+
\ No newline at end of file
diff --git a/Tutorial 3/App.config b/Tutorial 3/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/Tutorial 3/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tutorial 3/Form1.Designer.cs b/Tutorial 3/Form1.Designer.cs
new file mode 100644
index 0000000..cac84d0
--- /dev/null
+++ b/Tutorial 3/Form1.Designer.cs
@@ -0,0 +1,41 @@
+
+namespace Tutorial_3
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Text = "Form1";
+ }
+
+ #endregion
+ }
+}
+
diff --git a/Tutorial 3/Form1.cs b/Tutorial 3/Form1.cs
new file mode 100644
index 0000000..c0966db
--- /dev/null
+++ b/Tutorial 3/Form1.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Tutorial_3
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Tutorial 3/IProduct.cs b/Tutorial 3/IProduct.cs
new file mode 100644
index 0000000..0720014
--- /dev/null
+++ b/Tutorial 3/IProduct.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tutorial_3
+{
+ interface IProduct
+ {
+ string GetName { get; }
+ decimal GetValue { get; }
+ // Extra definitions here
+
+
+ }
+}
diff --git a/Tutorial 3/IStoreFront.cs b/Tutorial 3/IStoreFront.cs
new file mode 100644
index 0000000..2c3d6ff
--- /dev/null
+++ b/Tutorial 3/IStoreFront.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tutorial_3
+{
+ interface IStoreFront
+ {
+ string GetName { get; }
+ string GetAddress { get; }
+ string GetPhoneNumber { get; }
+ DateTime[] GetOpenHours { get; }
+ TimeSpan[] GetOpenTime { get; }
+
+
+ List GetProducts { get; }
+ }
+}
diff --git a/Tutorial 3/Program.cs b/Tutorial 3/Program.cs
new file mode 100644
index 0000000..2352864
--- /dev/null
+++ b/Tutorial 3/Program.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Tutorial_3
+{
+ static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/Tutorial 3/Properties/AssemblyInfo.cs b/Tutorial 3/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..eb7a35f
--- /dev/null
+++ b/Tutorial 3/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tutorial 3")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tutorial 3")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("62ac24e6-5c4f-414c-aeaa-9406b825ffb8")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tutorial 3/Properties/Resources.Designer.cs b/Tutorial 3/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..319d56e
--- /dev/null
+++ b/Tutorial 3/Properties/Resources.Designer.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace Tutorial_3.Properties
+{
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tutorial_3.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Tutorial 3/Properties/Resources.resx b/Tutorial 3/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/Tutorial 3/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Tutorial 3/Properties/Settings.Designer.cs b/Tutorial 3/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..873a50b
--- /dev/null
+++ b/Tutorial 3/Properties/Settings.Designer.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace Tutorial_3.Properties
+{
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/Tutorial 3/Properties/Settings.settings b/Tutorial 3/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/Tutorial 3/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/Tutorial 3/Tutorial 3.csproj b/Tutorial 3/Tutorial 3.csproj
new file mode 100644
index 0000000..9ee2080
--- /dev/null
+++ b/Tutorial 3/Tutorial 3.csproj
@@ -0,0 +1,83 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {62AC24E6-5C4F-414C-AEAA-9406B825FFB8}
+ WinExe
+ Tutorial_3
+ Tutorial 3
+ v4.7.2
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tutorial 3/Tutorial 3.pdf b/Tutorial 3/Tutorial 3.pdf
new file mode 100644
index 0000000..99e0dac
--- /dev/null
+++ b/Tutorial 3/Tutorial 3.pdf
@@ -0,0 +1,66 @@
+158.326 Software Construction – Semester 2
+
+Tutorials 3
+
+Create a class diagram based on the following case scenario. Next, implement the class diagram
+thru a project in Visual Studio.
+
+CASE
+There are many different types of testing stations nationwide for conducting vehicle inspections.
+Each testing station has a registered name, an address and a contact telephone number. Some of
+the testing stations which conduct car and truck inspections are VTNZ, DriveSafe, NZ- WoF, and
+AA.
+
+You have to design an application for car inspections done by VTNZ testing station.
+
+VTNZ offers many services for inspections. Different service types and prices apply for car and
+truck inspections. For car inspections, the service type and service price are given in Table 1.
+
+ Service Type Table 1
+
+ WoF inspection Service Price
+ Modified vehicle check-up
+ Pre-purchase inspection $ 50.00
+ Certificate of Fitness $ 200.00
+ $ 150.00
+ $ 210.00
+
+Part A:
+
+Name each class
+
+ 1. __________________
+ 2. __________________
+ 3. __________________
+ 4. __________________
+
+How many abstract classes do you have? _____________________
+How many are interfaces do you have? ______________________
+How many concrete classes? ______________________
+
+Draw the class diagram, showing the relationship between them.
+
+ 1
+Hint: The class diagram is similar to the example done in class. You should use all OO concepts
+covered in class (i.e., inheritance, wrapper/ interface and association) for a flexible design which
+can be extended.
+NOTE: Use proper naming conventions e.g. use camelCase, prefix private fields with _ and prefix
+protected fields with z.
+Part B:
+Create a new project in Visual Studio and implement the design using the class diagram identified
+in Part A.
+Further, note that VTNZ wants to keep track of the total number of inspections carried out and the
+total price for them.
+To illustrate this screen shots on the following pages show you
+(1) the basic form design,
+(2) what will be displayed after the FormLoad event,
+(3) what will be displayed after one inspection is requested and
+(4) what will be displayed after two inspections are requested.
+Hints: The implementation will be similar to the example demonstrated in class.
+You will have to use shared/static fields/properties/methods to show summary information - ‘Total
+Number of Inspections Requested’ and ‘Total Price for all Inspections Requested’.
+
+ 2
+3
+4
+
\ No newline at end of file
diff --git a/Tutorial 3/VTNZ_StoreFront.cs b/Tutorial 3/VTNZ_StoreFront.cs
new file mode 100644
index 0000000..ef95272
--- /dev/null
+++ b/Tutorial 3/VTNZ_StoreFront.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tutorial_3
+{
+ class VTNZ_StoreFront : IStoreFront
+ {
+ string _storefrontName;
+ string _storefrontAddress;
+ string _storefrontPhoneNumber;
+ DateTime[] _storefrontOpeningTime;
+ TimeSpan[] _storefrontTimeOpen;
+
+ List _storeProducts;
+
+ public string GetName => _storefrontName;
+
+ public string GetAddress => _storefrontAddress;
+
+ public DateTime[] GetOpenHours => _storefrontOpeningTime;
+
+ public TimeSpan[] GetOpenTime => _storefrontTimeOpen;
+
+ public string GetPhoneNumber => _storefrontPhoneNumber;
+
+ public List GetProducts => _storeProducts;
+
+ public VTNZ_StoreFront(string name, string location, string phone, DateTime[] dayStartTimes, TimeSpan[] dayLengths)
+ {
+ _storefrontName = name;
+ _storefrontAddress = location;
+ _storefrontPhoneNumber = phone;
+ _storefrontOpeningTime = dayStartTimes;
+ _storefrontTimeOpen = dayLengths;
+
+ _storeProducts = new List();
+ }
+ }
+}
diff --git a/Tutorial 4/App.config b/Tutorial 4/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/Tutorial 4/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tutorial 4/Form1.Designer.cs b/Tutorial 4/Form1.Designer.cs
new file mode 100644
index 0000000..5249d16
--- /dev/null
+++ b/Tutorial 4/Form1.Designer.cs
@@ -0,0 +1,84 @@
+
+namespace Tutorial_4
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.ServiceCheckListBox = new System.Windows.Forms.CheckedListBox();
+ this.StorefrontSelectBox = new System.Windows.Forms.ListBox();
+ this.monthCalendar1 = new System.Windows.Forms.MonthCalendar();
+ this.SuspendLayout();
+ //
+ // ServiceCheckListBox
+ //
+ this.ServiceCheckListBox.Font = new System.Drawing.Font("Consolas", 7.875F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.ServiceCheckListBox.FormattingEnabled = true;
+ this.ServiceCheckListBox.Location = new System.Drawing.Point(161, 167);
+ this.ServiceCheckListBox.Name = "ServiceCheckListBox";
+ this.ServiceCheckListBox.Size = new System.Drawing.Size(445, 200);
+ this.ServiceCheckListBox.TabIndex = 0;
+ this.ServiceCheckListBox.SelectedIndexChanged += new System.EventHandler(this.ServiceCheckListBox_SelectedIndexChanged);
+ //
+ // StorefrontSelectBox
+ //
+ this.StorefrontSelectBox.FormattingEnabled = true;
+ this.StorefrontSelectBox.ItemHeight = 25;
+ this.StorefrontSelectBox.Location = new System.Drawing.Point(161, 67);
+ this.StorefrontSelectBox.Name = "StorefrontSelectBox";
+ this.StorefrontSelectBox.Size = new System.Drawing.Size(445, 79);
+ this.StorefrontSelectBox.TabIndex = 1;
+ this.StorefrontSelectBox.SelectedIndexChanged += new System.EventHandler(this.StorefrontSelectBox_SelectedIndexChanged);
+ //
+ // monthCalendar1
+ //
+ this.monthCalendar1.Location = new System.Drawing.Point(882, 182);
+ this.monthCalendar1.Name = "monthCalendar1";
+ this.monthCalendar1.TabIndex = 2;
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1383, 835);
+ this.Controls.Add(this.monthCalendar1);
+ this.Controls.Add(this.StorefrontSelectBox);
+ this.Controls.Add(this.ServiceCheckListBox);
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.CheckedListBox ServiceCheckListBox;
+ private System.Windows.Forms.ListBox StorefrontSelectBox;
+ private System.Windows.Forms.MonthCalendar monthCalendar1;
+ }
+}
+
diff --git a/Tutorial 4/Form1.cs b/Tutorial 4/Form1.cs
new file mode 100644
index 0000000..420246a
--- /dev/null
+++ b/Tutorial 4/Form1.cs
@@ -0,0 +1,48 @@
+using AppLogic;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Tutorial_4
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+
+ StorefrontSelectBox.DataSource = Program.storeFronts;
+ StorefrontSelectBox.ClearSelected();
+ ServiceCheckListBox.Items.Clear();
+ //
+
+ }
+
+ private void StorefrontSelectBox_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ IStoreFront selectedStore = (IStoreFront)(StorefrontSelectBox.SelectedItem);
+ if (selectedStore != null)
+ {
+ ServiceCheckListBox.Items.Clear();
+ foreach (var item in selectedStore.GetProducts)
+ {
+ ServiceCheckListBox.Items.Add(item, false);
+ }
+ }
+ Program.storeFronts.Add(Program.storeFronts.First());
+
+
+ }
+
+ private void ServiceCheckListBox_SelectedIndexChanged(object sender, EventArgs e)
+ {
+
+ }
+ }
+}
diff --git a/Tutorial 4/Form1.resx b/Tutorial 4/Form1.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/Tutorial 4/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Tutorial 4/Program.cs b/Tutorial 4/Program.cs
new file mode 100644
index 0000000..d04c9fe
--- /dev/null
+++ b/Tutorial 4/Program.cs
@@ -0,0 +1,33 @@
+using AppLogic;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Tutorial_4
+{
+ static class Program
+ {
+ public static List storeFronts;
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ // These could be fed via file
+ storeFronts = new List();
+ string[] days = new string[] { "Monday", "Tuesday" };
+ TimeSpan[] times = new TimeSpan[] { TimeSpan.FromHours(7), TimeSpan.FromHours(8).Add(TimeSpan.FromMinutes(30)) };
+
+ storeFronts.Add(new VTNZ_StoreFront("VTNZ Albany", "21 Albany Highway", "099900999", days, times));
+ storeFronts.Add(new CompetitorStoreFront("Other Competitor", "22 Albany Highway", "099900990", days, times));
+
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+
+ }
+ }
+}
diff --git a/Tutorial 4/Properties/AssemblyInfo.cs b/Tutorial 4/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..eb7a35f
--- /dev/null
+++ b/Tutorial 4/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tutorial 3")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tutorial 3")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("62ac24e6-5c4f-414c-aeaa-9406b825ffb8")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tutorial 4/Properties/Resources.Designer.cs b/Tutorial 4/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..319d56e
--- /dev/null
+++ b/Tutorial 4/Properties/Resources.Designer.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace Tutorial_3.Properties
+{
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tutorial_3.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Tutorial 4/Properties/Resources.resx b/Tutorial 4/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/Tutorial 4/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Tutorial 4/Properties/Settings.Designer.cs b/Tutorial 4/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..873a50b
--- /dev/null
+++ b/Tutorial 4/Properties/Settings.Designer.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace Tutorial_3.Properties
+{
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/Tutorial 4/Properties/Settings.settings b/Tutorial 4/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/Tutorial 4/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/Tutorial 4/Tutorial 4.csproj b/Tutorial 4/Tutorial 4.csproj
new file mode 100644
index 0000000..5962517
--- /dev/null
+++ b/Tutorial 4/Tutorial 4.csproj
@@ -0,0 +1,89 @@
+
+
+
+
+ Debug
+ AnyCPU
+
+ WinExe
+ Tutorial_4
+ Tutorial 4
+ v4.7.2
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+ Form1.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
+ {f3a4e792-4405-45a5-953d-93e3618e3e46}
+ AppLogic
+
+
+
+
\ No newline at end of file
diff --git a/Tutorial 4/Tutorials 4.pdf b/Tutorial 4/Tutorials 4.pdf
new file mode 100644
index 0000000..d340738
--- /dev/null
+++ b/Tutorial 4/Tutorials 4.pdf
@@ -0,0 +1,12 @@
+158.326 Software Construction – Semester 2
+Tutorial 4
+
+ 1. Complete Tutorial 3 case with correct use of Adapter Pattern and with collections (Lists/
+ Dictionaries)
+
+ 2. Re-do all the previous tutorial exercise with good housekeeping layouts. The boundary
+ class should access the control classes via dlls.
+
+ 3. Revise all the object-oriented concepts and their implementation aspects for Test 1
+1
+
\ No newline at end of file
diff --git a/Tutorial 5/App.config b/Tutorial 5/App.config
new file mode 100644
index 0000000..8e15646
--- /dev/null
+++ b/Tutorial 5/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tutorial 5/CurrentConditionsDisplay.Designer.cs b/Tutorial 5/CurrentConditionsDisplay.Designer.cs
new file mode 100644
index 0000000..442b4e5
--- /dev/null
+++ b/Tutorial 5/CurrentConditionsDisplay.Designer.cs
@@ -0,0 +1,138 @@
+
+namespace Tutorial_5
+{
+ partial class CurrentConditionsDisplay
+ {
+
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.PressureLabel = new System.Windows.Forms.Label();
+ this.HumidityLabel = new System.Windows.Forms.Label();
+ this.TemperatureLabel = new System.Windows.Forms.Label();
+ this.RegisterButton = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(174, 59);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(146, 25);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Temperature: ";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(213, 84);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(107, 25);
+ this.label2.TabIndex = 1;
+ this.label2.Text = "Humidity: ";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(213, 109);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(110, 25);
+ this.label3.TabIndex = 2;
+ this.label3.Text = "Pressure: ";
+ //
+ // PressureLabel
+ //
+ this.PressureLabel.AutoSize = true;
+ this.PressureLabel.Location = new System.Drawing.Point(326, 109);
+ this.PressureLabel.Name = "PressureLabel";
+ this.PressureLabel.Size = new System.Drawing.Size(110, 25);
+ this.PressureLabel.TabIndex = 5;
+ this.PressureLabel.Text = "Pressure: ";
+ //
+ // HumidityLabel
+ //
+ this.HumidityLabel.AutoSize = true;
+ this.HumidityLabel.Location = new System.Drawing.Point(326, 84);
+ this.HumidityLabel.Name = "HumidityLabel";
+ this.HumidityLabel.Size = new System.Drawing.Size(107, 25);
+ this.HumidityLabel.TabIndex = 4;
+ this.HumidityLabel.Text = "Humidity: ";
+ //
+ // TemperatureLabel
+ //
+ this.TemperatureLabel.AutoSize = true;
+ this.TemperatureLabel.Location = new System.Drawing.Point(326, 59);
+ this.TemperatureLabel.Name = "TemperatureLabel";
+ this.TemperatureLabel.Size = new System.Drawing.Size(146, 25);
+ this.TemperatureLabel.TabIndex = 3;
+ this.TemperatureLabel.Text = "Temperature: ";
+ //
+ // RegisterButton
+ //
+ this.RegisterButton.Location = new System.Drawing.Point(218, 269);
+ this.RegisterButton.Name = "RegisterButton";
+ this.RegisterButton.Size = new System.Drawing.Size(297, 42);
+ this.RegisterButton.TabIndex = 6;
+ this.RegisterButton.Text = "Register Component";
+ this.RegisterButton.UseVisualStyleBackColor = true;
+ this.RegisterButton.Click += new System.EventHandler(this.RegisterButton_Click);
+ //
+ // CurrentConditionsDisplay
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.RegisterButton);
+ this.Controls.Add(this.PressureLabel);
+ this.Controls.Add(this.HumidityLabel);
+ this.Controls.Add(this.TemperatureLabel);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Name = "CurrentConditionsDisplay";
+ this.Text = "CurrentConditionsDisplay";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+
+
+ #endregion
+
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label PressureLabel;
+ private System.Windows.Forms.Label HumidityLabel;
+ private System.Windows.Forms.Label TemperatureLabel;
+ private System.Windows.Forms.Button RegisterButton;
+ }
+}
\ No newline at end of file
diff --git a/Tutorial 5/CurrentConditionsDisplay.cs b/Tutorial 5/CurrentConditionsDisplay.cs
new file mode 100644
index 0000000..72d2a2b
--- /dev/null
+++ b/Tutorial 5/CurrentConditionsDisplay.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Tutorial_5
+{
+ public partial class CurrentConditionsDisplay : Form, IWeatherObserver, IDisplay
+ {
+ ISubject subject;
+ WeatherData weatherData;
+ private void RegisterButton_Click(object sender, EventArgs e)
+ {
+ subject.RegisterObserver(this);
+ }
+
+ double temperature = default, humidity = default, pressure = default;
+ public void Update(double temperature, double humidity, double pressure)
+ {
+ this.temperature = temperature;
+ this.humidity = humidity;
+ this.pressure = pressure;
+ Display();
+ }
+
+ public void UpdateOther()
+ {
+ this.temperature = weatherData.GetTemperature();
+ this.humidity = weatherData.GetHumidity();
+ this.pressure = weatherData.GetPressure();
+ }
+
+ public void Display()
+ {
+ TemperatureLabel.Text = temperature.ToString() + " ℃";
+ HumidityLabel.Text = humidity.ToString() + " %";
+ PressureLabel.Text = pressure.ToString() + " kPa";
+ }
+
+ public CurrentConditionsDisplay(ISubject subject)
+ {
+ InitializeComponent();
+ this.subject = subject;
+ }
+ }
+}
diff --git a/Tutorial 5/CurrentConditionsDisplay.resx b/Tutorial 5/CurrentConditionsDisplay.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/Tutorial 5/CurrentConditionsDisplay.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Tutorial 5/Form1.Designer.cs b/Tutorial 5/Form1.Designer.cs
new file mode 100644
index 0000000..a682f29
--- /dev/null
+++ b/Tutorial 5/Form1.Designer.cs
@@ -0,0 +1,245 @@
+
+namespace Tutorial_5
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.TemperatureSlider = new System.Windows.Forms.TrackBar();
+ this.Temperature = new System.Windows.Forms.Label();
+ this.TemperatureLabel = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
+ this.HumidityLabel = new System.Windows.Forms.Label();
+ this.label7 = new System.Windows.Forms.Label();
+ this.HumiditySlider = new System.Windows.Forms.TrackBar();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label8 = new System.Windows.Forms.Label();
+ this.PressureLabel = new System.Windows.Forms.Label();
+ this.label10 = new System.Windows.Forms.Label();
+ this.PressureSlider = new System.Windows.Forms.TrackBar();
+ ((System.ComponentModel.ISupportInitialize)(this.TemperatureSlider)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.HumiditySlider)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PressureSlider)).BeginInit();
+ this.SuspendLayout();
+ //
+ // TemperatureSlider
+ //
+ this.TemperatureSlider.LargeChange = 10;
+ this.TemperatureSlider.Location = new System.Drawing.Point(153, 35);
+ this.TemperatureSlider.Maximum = 100;
+ this.TemperatureSlider.Minimum = -45;
+ this.TemperatureSlider.Name = "TemperatureSlider";
+ this.TemperatureSlider.Size = new System.Drawing.Size(562, 90);
+ this.TemperatureSlider.TabIndex = 0;
+ this.TemperatureSlider.Value = 20;
+ this.TemperatureSlider.ValueChanged += new System.EventHandler(this.SliderChanged);
+ //
+ // Temperature
+ //
+ this.Temperature.AutoSize = true;
+ this.Temperature.Location = new System.Drawing.Point(13, 35);
+ this.Temperature.Name = "Temperature";
+ this.Temperature.Size = new System.Drawing.Size(134, 25);
+ this.Temperature.TabIndex = 1;
+ this.Temperature.Text = "Temperature";
+ //
+ // TemperatureLabel
+ //
+ this.TemperatureLabel.AutoSize = true;
+ this.TemperatureLabel.Location = new System.Drawing.Point(721, 35);
+ this.TemperatureLabel.Name = "TemperatureLabel";
+ this.TemperatureLabel.Size = new System.Drawing.Size(59, 25);
+ this.TemperatureLabel.TabIndex = 2;
+ this.TemperatureLabel.Text = "25 ℃";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(656, 85);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(71, 25);
+ this.label2.TabIndex = 3;
+ this.label2.Text = "100 ℃";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(148, 85);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(66, 25);
+ this.label3.TabIndex = 4;
+ this.label3.Text = "-45 ℃";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(148, 178);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(49, 25);
+ this.label4.TabIndex = 9;
+ this.label4.Text = "0 %";
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(656, 178);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(73, 25);
+ this.label5.TabIndex = 8;
+ this.label5.Text = "100 %";
+ //
+ // HumidityLabel
+ //
+ this.HumidityLabel.AutoSize = true;
+ this.HumidityLabel.Location = new System.Drawing.Point(721, 128);
+ this.HumidityLabel.Name = "HumidityLabel";
+ this.HumidityLabel.Size = new System.Drawing.Size(55, 25);
+ this.HumidityLabel.TabIndex = 7;
+ this.HumidityLabel.Text = "50%";
+ //
+ // label7
+ //
+ this.label7.AutoSize = true;
+ this.label7.Location = new System.Drawing.Point(13, 128);
+ this.label7.Name = "label7";
+ this.label7.Size = new System.Drawing.Size(95, 25);
+ this.label7.TabIndex = 6;
+ this.label7.Text = "Humidity";
+ //
+ // HumiditySlider
+ //
+ this.HumiditySlider.LargeChange = 10;
+ this.HumiditySlider.Location = new System.Drawing.Point(153, 128);
+ this.HumiditySlider.Maximum = 100;
+ this.HumiditySlider.Name = "HumiditySlider";
+ this.HumiditySlider.Size = new System.Drawing.Size(562, 90);
+ this.HumiditySlider.TabIndex = 5;
+ this.HumiditySlider.Value = 20;
+ this.HumiditySlider.ValueChanged += new System.EventHandler(this.SliderChanged);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(148, 274);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(91, 25);
+ this.label1.TabIndex = 14;
+ this.label1.Text = "900 kPa";
+ //
+ // label8
+ //
+ this.label8.AutoSize = true;
+ this.label8.Location = new System.Drawing.Point(656, 274);
+ this.label8.Name = "label8";
+ this.label8.Size = new System.Drawing.Size(103, 25);
+ this.label8.TabIndex = 13;
+ this.label8.Text = "1100 kPa";
+ //
+ // PressureLabel
+ //
+ this.PressureLabel.AutoSize = true;
+ this.PressureLabel.Location = new System.Drawing.Point(721, 224);
+ this.PressureLabel.Name = "PressureLabel";
+ this.PressureLabel.Size = new System.Drawing.Size(103, 25);
+ this.PressureLabel.TabIndex = 12;
+ this.PressureLabel.Text = "1014 kPa";
+ //
+ // label10
+ //
+ this.label10.AutoSize = true;
+ this.label10.Location = new System.Drawing.Point(13, 224);
+ this.label10.Name = "label10";
+ this.label10.Size = new System.Drawing.Size(98, 25);
+ this.label10.TabIndex = 11;
+ this.label10.Text = "Pressure";
+ //
+ // PressureSlider
+ //
+ this.PressureSlider.LargeChange = 10;
+ this.PressureSlider.Location = new System.Drawing.Point(153, 224);
+ this.PressureSlider.Maximum = 1100;
+ this.PressureSlider.Minimum = 900;
+ this.PressureSlider.Name = "PressureSlider";
+ this.PressureSlider.Size = new System.Drawing.Size(562, 90);
+ this.PressureSlider.TabIndex = 10;
+ this.PressureSlider.Value = 1014;
+ this.PressureSlider.ValueChanged += new System.EventHandler(this.SliderChanged);
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1061, 548);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.label8);
+ this.Controls.Add(this.PressureLabel);
+ this.Controls.Add(this.label10);
+ this.Controls.Add(this.PressureSlider);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.label5);
+ this.Controls.Add(this.HumidityLabel);
+ this.Controls.Add(this.label7);
+ this.Controls.Add(this.HumiditySlider);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.TemperatureLabel);
+ this.Controls.Add(this.Temperature);
+ this.Controls.Add(this.TemperatureSlider);
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.Load += new System.EventHandler(this.Form1_Load_1);
+ ((System.ComponentModel.ISupportInitialize)(this.TemperatureSlider)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.HumiditySlider)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.PressureSlider)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TrackBar TemperatureSlider;
+ private System.Windows.Forms.Label Temperature;
+ private System.Windows.Forms.Label TemperatureLabel;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.Label HumidityLabel;
+ private System.Windows.Forms.Label label7;
+ private System.Windows.Forms.TrackBar HumiditySlider;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label8;
+ private System.Windows.Forms.Label PressureLabel;
+ private System.Windows.Forms.Label label10;
+ private System.Windows.Forms.TrackBar PressureSlider;
+ }
+}
+
diff --git a/Tutorial 5/Form1.cs b/Tutorial 5/Form1.cs
new file mode 100644
index 0000000..505320d
--- /dev/null
+++ b/Tutorial 5/Form1.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Tutorial_5
+{
+ public partial class Form1 : Form
+ {
+ ISubject subject;
+ public Form1()
+ {
+ InitializeComponent();
+ this.subject = new WeatherData();
+
+
+ }
+
+ private void Form1_Load(object sender, EventArgs e)
+ {
+
+ }
+
+ private void SliderChanged(object sender, EventArgs e)
+ {
+ subject.NotifyObservers();
+ TemperatureLabel.Text = TemperatureSlider.Value.ToString() + " ℃";
+ HumidityLabel.Text = HumiditySlider.Value.ToString() + " %";
+ PressureLabel.Text = PressureSlider.Value.ToString() + " kPa";
+ }
+
+ private void Form1_Load_1(object sender, EventArgs e)
+ {
+ CurrentConditionsDisplay ccd = new CurrentConditionsDisplay(this.subject);
+ ccd.Show();
+ }
+ }
+}
diff --git a/Tutorial 5/Form1.resx b/Tutorial 5/Form1.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/Tutorial 5/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Tutorial 5/IDisplay.cs b/Tutorial 5/IDisplay.cs
new file mode 100644
index 0000000..10464b0
--- /dev/null
+++ b/Tutorial 5/IDisplay.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tutorial_5
+{
+ interface IDisplay
+ {
+ void Display();
+ }
+}
diff --git a/Tutorial 5/IObserver.cs b/Tutorial 5/IObserver.cs
new file mode 100644
index 0000000..bccf7ca
--- /dev/null
+++ b/Tutorial 5/IObserver.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tutorial_5
+{
+ public interface IWeatherObserver
+ {
+ void Update(double temperature, double humidity, double pressure);
+ }
+}
diff --git a/Tutorial 5/ISubject.cs b/Tutorial 5/ISubject.cs
new file mode 100644
index 0000000..97f0d5b
--- /dev/null
+++ b/Tutorial 5/ISubject.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tutorial_5
+{
+ public interface ISubject
+ {
+ void RegisterObserver(IWeatherObserver observer);
+ void DeregisterObserver(IWeatherObserver observer);
+ void NotifyObservers();
+ }
+}
diff --git a/Tutorial 5/Program.cs b/Tutorial 5/Program.cs
new file mode 100644
index 0000000..a69b8c9
--- /dev/null
+++ b/Tutorial 5/Program.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Tutorial_5
+{
+ static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+
+ }
+ }
+}
diff --git a/Tutorial 5/Properties/AssemblyInfo.cs b/Tutorial 5/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..56d5f3b
--- /dev/null
+++ b/Tutorial 5/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tutorial 5")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tutorial 5")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("7256bbb8-354f-467c-8377-f01c4cae956e")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tutorial 5/Properties/Resources.Designer.cs b/Tutorial 5/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..dfd0ad5
--- /dev/null
+++ b/Tutorial 5/Properties/Resources.Designer.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace Tutorial_5.Properties
+{
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tutorial_5.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Tutorial 5/Properties/Resources.resx b/Tutorial 5/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/Tutorial 5/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Tutorial 5/Properties/Settings.Designer.cs b/Tutorial 5/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..ca76150
--- /dev/null
+++ b/Tutorial 5/Properties/Settings.Designer.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace Tutorial_5.Properties
+{
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/Tutorial 5/Properties/Settings.settings b/Tutorial 5/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/Tutorial 5/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/Tutorial 5/ThirdPartyDisplay.cs b/Tutorial 5/ThirdPartyDisplay.cs
new file mode 100644
index 0000000..15a0ce9
--- /dev/null
+++ b/Tutorial 5/ThirdPartyDisplay.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tutorial_5
+{
+ class ThirdPartyDisplay : IWeatherObserver
+ {
+ public void Update(double temperature, double humidity, double pressure)
+ {
+ throw new NotImplementedException();
+ }
+
+ void Display()
+ {
+
+ }
+ }
+}
diff --git a/Tutorial 5/Tutorial 5.csproj b/Tutorial 5/Tutorial 5.csproj
new file mode 100644
index 0000000..cb9e440
--- /dev/null
+++ b/Tutorial 5/Tutorial 5.csproj
@@ -0,0 +1,96 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {7256BBB8-354F-467C-8377-F01C4CAE956E}
+ WinExe
+ Tutorial_5
+ Tutorial 5
+ v4.5
+ 512
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ CurrentConditionsDisplay.cs
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+
+
+
+
+
+ CurrentConditionsDisplay.cs
+
+
+ Form1.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tutorial 5/Tutorial 5.pdf b/Tutorial 5/Tutorial 5.pdf
new file mode 100644
index 0000000..6ba3f3e
--- /dev/null
+++ b/Tutorial 5/Tutorial 5.pdf
@@ -0,0 +1,50 @@
+158.326 Software Construction
+Tutorial 5
+In this tutorial you will be implementing the Observer pattern covered in the lecture 5, using the Weather Station
+case study found in chapter 2 of “Head First Design Patterns”. Below is the class diagram for this case study,
+implemented using the Observer pattern.
+We will implement the Observer pattern for this case study as a Windows Forms application that comprises of 4
+forms. From the diagram below, WeatherData, CurrentConditionDisplay, ForecastDisplay and StatisticsDisplay
+classes will be a separate Form class each. Ignore the ThirdPartyDisplay class in the diagram.
+We will build this application incrementally, one display form at a time.
+
+ Image from “Head First Design Patterns” by Eric Freeman, Elisabeth Robson, Bert Bates, Kathy Sierra
+Exercise 1
+Create a C# windows forms project. Define the 3 interfaces from the diagram. First create the WeatherData form
+that looks something like the image below left, in which one can enter the temperature, humidity and pressure
+values. Choose yourself what type of a user event you would like to be triggered that will read the text box values
+and store them into variables in your form (floats or ints). Next, implement the interface methods in the form and
+any other methods you might need.
+
+Next create the CurrentConditionsDisplay form that looks something like the form above right, whose functionality is
+to display values from the WeatherData form when it is registered as an observer. Implement the interfaces’
+methods and the button click events. For the Update() method in the Observer interface, use the push technique
+to update the observer objects as shown in the book. That means that the Update() method will be taking the
+temperature, humidity and pressure values as arguments and passing them to all the observers. Define the
+constructors in both the CurrentConditionsDisplay and WeatherData forms as shown in the class as well as in the
+supplementary lecture slides in order to create a multi-form application.
+Once you have connected everything up and launched your application, whatever is typed into the WeatherData
+form should be reflected in the CurrentConditions form when the observer form registers as an observer with the
+subject, as shown in the images below.
+Exercise 2
+Extend the application by adding the ForecastDisplay form as pictured below.
+
+Implement very naïve logic which sets the “Expected conditions” label as “Sunshine” if the pressure in the
+WeatherData form is above 1000, otherwise as “Rain”.
+Exercise 3
+Extend the application further by adding the StatisticsDisplay form as pictured below.
+
+This form will keep track of all the temperature entries during the periods when it was registered as an observer, and
+will provide simple statistics such as the average, maximum and the minimum temperatures experienced.
+Exercise 4
+You have now seen how the Observer patterns works. There are, however, different ways of implementing it. You
+have implemented the Observer pattern using the push technique, whereby it is the Subject who decides what data
+to update the observers with. As an exercise, now modify your code to implement the pull technique. Start by adding
+a new method to the Observer interface called UpdatePull() which unlike the Update() method, takes no
+arguments. Modify your program in such a way that enables the observers to fetch the data they specifically need
+from the Subject.
+Exercise 5
+Add another interface INotes to the three Display Elements which has one method WeatherNotes()which gives
+both new and previous reading of relevant weather changes, i.e., Weather Statistics gives temperature changes only,
+etc.
+
\ No newline at end of file
diff --git a/Tutorial 5/WeatherData.cs b/Tutorial 5/WeatherData.cs
new file mode 100644
index 0000000..89de336
--- /dev/null
+++ b/Tutorial 5/WeatherData.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tutorial_5
+{
+ class WeatherData : ISubject
+ {
+ List observers;
+ public void DeregisterObserver(IWeatherObserver observer)
+ {
+ if (observers.Contains(observer)) observers.Remove(observer);
+ else Console.Error.WriteLine("{0} does not exist in the observers list.", observer.ToString());
+ }
+
+ public void NotifyObservers()
+ {
+ double t = GetTemperature();
+ double h = GetHumidity();
+ double p = GetPressure();
+
+ foreach (var observer in observers)
+ {
+ observer.Update(t,h,p);
+ }
+ }
+
+ public void RegisterObserver(IWeatherObserver observer)
+ {
+ if (observers.Contains(observer)) Console.Error.WriteLine("{0} already exists in the observers list.", observer.ToString());
+ else observers.Add(observer);
+ }
+
+ public double GetTemperature()
+ {
+ return 0.0;
+ }
+
+ public double GetHumidity()
+ {
+ return 0.0;
+ }
+
+ public double GetPressure()
+ {
+ return 0.0;
+ }
+
+ void MeasurementChanged()
+ {
+ NotifyObservers();
+ }
+
+ public WeatherData()
+ {
+ observers = new List();
+ }
+ }
+}
diff --git a/Tutorial 6/App.config b/Tutorial 6/App.config
new file mode 100644
index 0000000..8e15646
--- /dev/null
+++ b/Tutorial 6/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tutorial 6/Form1.Designer.cs b/Tutorial 6/Form1.Designer.cs
new file mode 100644
index 0000000..ca3bfc7
--- /dev/null
+++ b/Tutorial 6/Form1.Designer.cs
@@ -0,0 +1,152 @@
+
+namespace Duck_Simulator
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.checkBox1 = new System.Windows.Forms.CheckBox();
+ this.checkBox2 = new System.Windows.Forms.CheckBox();
+ this.checkBox3 = new System.Windows.Forms.CheckBox();
+ this.checkBox4 = new System.Windows.Forms.CheckBox();
+ this.button1 = new System.Windows.Forms.Button();
+ this.button2 = new System.Windows.Forms.Button();
+ this.button3 = new System.Windows.Forms.Button();
+ this.groupBox1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.checkBox4);
+ this.groupBox1.Controls.Add(this.checkBox3);
+ this.groupBox1.Controls.Add(this.checkBox2);
+ this.groupBox1.Controls.Add(this.checkBox1);
+ this.groupBox1.Location = new System.Drawing.Point(12, 12);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(644, 911);
+ this.groupBox1.TabIndex = 0;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Duck Selector";
+ //
+ // checkBox1
+ //
+ this.checkBox1.AutoSize = true;
+ this.checkBox1.Location = new System.Drawing.Point(39, 42);
+ this.checkBox1.Name = "checkBox1";
+ this.checkBox1.Size = new System.Drawing.Size(170, 29);
+ this.checkBox1.TabIndex = 0;
+ this.checkBox1.Text = "Mallard Duck";
+ this.checkBox1.UseVisualStyleBackColor = true;
+ //
+ // checkBox2
+ //
+ this.checkBox2.AutoSize = true;
+ this.checkBox2.Location = new System.Drawing.Point(39, 77);
+ this.checkBox2.Name = "checkBox2";
+ this.checkBox2.Size = new System.Drawing.Size(186, 29);
+ this.checkBox2.TabIndex = 1;
+ this.checkBox2.Text = "Redhead Duck";
+ this.checkBox2.UseVisualStyleBackColor = true;
+ //
+ // checkBox3
+ //
+ this.checkBox3.AutoSize = true;
+ this.checkBox3.Location = new System.Drawing.Point(39, 112);
+ this.checkBox3.Name = "checkBox3";
+ this.checkBox3.Size = new System.Drawing.Size(180, 29);
+ this.checkBox3.TabIndex = 2;
+ this.checkBox3.Text = "Rubber Ducky";
+ this.checkBox3.UseVisualStyleBackColor = true;
+ //
+ // checkBox4
+ //
+ this.checkBox4.AutoSize = true;
+ this.checkBox4.Location = new System.Drawing.Point(39, 147);
+ this.checkBox4.Name = "checkBox4";
+ this.checkBox4.Size = new System.Drawing.Size(160, 29);
+ this.checkBox4.TabIndex = 3;
+ this.checkBox4.Text = "Decoy Duck";
+ this.checkBox4.UseVisualStyleBackColor = true;
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(682, 36);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(134, 47);
+ this.button1.TabIndex = 4;
+ this.button1.Text = "Quack";
+ this.button1.UseVisualStyleBackColor = true;
+ //
+ // button2
+ //
+ this.button2.Location = new System.Drawing.Point(682, 106);
+ this.button2.Name = "button2";
+ this.button2.Size = new System.Drawing.Size(134, 47);
+ this.button2.TabIndex = 5;
+ this.button2.Text = "Fly";
+ this.button2.UseVisualStyleBackColor = true;
+ //
+ // button3
+ //
+ this.button3.Location = new System.Drawing.Point(682, 179);
+ this.button3.Name = "button3";
+ this.button3.Size = new System.Drawing.Size(134, 47);
+ this.button3.TabIndex = 6;
+ this.button3.Text = "Swim";
+ this.button3.UseVisualStyleBackColor = true;
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1497, 935);
+ this.Controls.Add(this.button3);
+ this.Controls.Add(this.button2);
+ this.Controls.Add(this.button1);
+ this.Controls.Add(this.groupBox1);
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.CheckBox checkBox4;
+ private System.Windows.Forms.CheckBox checkBox3;
+ private System.Windows.Forms.CheckBox checkBox2;
+ private System.Windows.Forms.CheckBox checkBox1;
+ private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.Button button2;
+ private System.Windows.Forms.Button button3;
+ }
+}
+
diff --git a/Tutorial 6/Form1.cs b/Tutorial 6/Form1.cs
new file mode 100644
index 0000000..151f889
--- /dev/null
+++ b/Tutorial 6/Form1.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Duck_Simulator
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Tutorial 6/Form1.resx b/Tutorial 6/Form1.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/Tutorial 6/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Tutorial 6/Program.cs b/Tutorial 6/Program.cs
new file mode 100644
index 0000000..1dcbcde
--- /dev/null
+++ b/Tutorial 6/Program.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Duck_Simulator
+{
+ static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/Tutorial 6/Properties/AssemblyInfo.cs b/Tutorial 6/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..dd4a405
--- /dev/null
+++ b/Tutorial 6/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Duck Simulator")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Duck Simulator")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("00702453-3ad5-4822-a38c-2859b52c3e4c")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tutorial 6/Properties/Resources.Designer.cs b/Tutorial 6/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..59b4cad
--- /dev/null
+++ b/Tutorial 6/Properties/Resources.Designer.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace Duck_Simulator.Properties
+{
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Duck_Simulator.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Tutorial 6/Properties/Resources.resx b/Tutorial 6/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/Tutorial 6/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Tutorial 6/Properties/Settings.Designer.cs b/Tutorial 6/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..6eba4b6
--- /dev/null
+++ b/Tutorial 6/Properties/Settings.Designer.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace Duck_Simulator.Properties
+{
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/Tutorial 6/Properties/Settings.settings b/Tutorial 6/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/Tutorial 6/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/Tutorial 6/Tutorial 6 2019.pdf b/Tutorial 6/Tutorial 6 2019.pdf
new file mode 100644
index 0000000..6a3f210
--- /dev/null
+++ b/Tutorial 6/Tutorial 6 2019.pdf
@@ -0,0 +1,27 @@
+158.326 Software Construction
+
+Tutorial 6
+
+Exercise 1
+
+Below is the class diagram of the Duck Simulator Program case study presented in Lecture 6 and found in Chapter 1
+of “Head First Design Patterns”.
+ Image from “Head First Design Patterns” by Eric Freeman, Elisabeth Robson, Bert Bates, Kathy Sierra
+
+Your first task is to implement this class diagram using C# as a DLL project. In order for us to be able to test this
+program in a Form, you will need to modify the class diagram slightly so that all behavioural methods return a string
+that will be displayed in a form. This means that the Display() method for the MallardDuck will return a string “I
+am a Mallard Duck”, for ReadheadDuck “I am a Readhead Duck” and so on. Likewise, each family of behaviour
+classes will return a string eg. fly behaviour classes like FlyWithWings will return “I can fly with my wings” when
+Fly() is called, while calling Fly() on FlyNoWay will return “I cannot fly” etc. Apply the same pattern to the
+QuackBehaviour classes. Remember to modify the PerformQuack() and PerformFly() methods in the Duck
+class so that they return a string as well.
+
+Exercise 2
+Once you have completed the implementation of the class diagram in exercise 1, you are ready to proceed and test it
+out. In this step you will create a new Windows Forms project and a single form that will reference and call into the
+DLL you created above. Below is the example of what your form should look like and the results it should display if
+Mallard duck selected and the Display button clicked (left) and followed by a click on the Fly button (right) :
+Likewise if the Rubber duck is selected and the Fly button is clicked the following should display (left), and if the
+Quack button is selected on the same duck then it should change accordingly (right):
+
\ No newline at end of file
diff --git a/Tutorial 6/Tutorial 6.csproj b/Tutorial 6/Tutorial 6.csproj
new file mode 100644
index 0000000..6ba4f0f
--- /dev/null
+++ b/Tutorial 6/Tutorial 6.csproj
@@ -0,0 +1,82 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {00702453-3AD5-4822-A38C-2859B52C3E4C}
+ WinExe
+ Duck_Simulator
+ Duck Simulator
+ v4.5
+ 512
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+ Form1.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VTNZ_Immutable/Class1.cs b/VTNZ_Immutable/Class1.cs
new file mode 100644
index 0000000..f22281c
--- /dev/null
+++ b/VTNZ_Immutable/Class1.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace VTNZ_Immutable
+{
+ public class General
+ {
+ string _name;
+ decimal _value;
+
+ public string Name => _name;
+ public decimal Value => _value;
+ public General(string name, int value)
+ {
+ _name = name;
+ _value = value;
+ }
+ }
+ public class WoFInspection
+ {
+ string _name = "Wof Inspection";
+ decimal _value = 50M;
+
+ public string Name => _name;
+ public decimal Value => _value;
+ }
+
+ public class ModifiedInspection
+ {
+ string _inspectionType = "Modified Vehicle Check-Up";
+ decimal _value = 200M;
+
+ public string InspectionType => _inspectionType;
+ public decimal Value => _value;
+ }
+
+ public class PrePurchaseInspection
+ {
+ string _name = "Pre-purchase Inspection";
+ decimal _value = 150M;
+
+ public string Name => _name;
+ public decimal Value => _value;
+ }
+
+ public class CoFInspection
+ {
+ string _name = "Wof Inspection";
+ decimal _value = 210M;
+
+ public string Name => _name;
+ public decimal Value => _value;
+ }
+}
diff --git a/VTNZ_Immutable/Properties/AssemblyInfo.cs b/VTNZ_Immutable/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..40f3a9c
--- /dev/null
+++ b/VTNZ_Immutable/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("VTNZ_Immutable")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("VTNZ_Immutable")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("6665e064-a51f-4e18-9333-157f41d29152")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/VTNZ_Immutable/VTNZ_Immutable.csproj b/VTNZ_Immutable/VTNZ_Immutable.csproj
new file mode 100644
index 0000000..a8554e0
--- /dev/null
+++ b/VTNZ_Immutable/VTNZ_Immutable.csproj
@@ -0,0 +1,54 @@
+
+
+
+
+ Debug
+ AnyCPU
+ 6665e064-a51f-4e18-9333-157f41d29152
+ Library
+ Properties
+ VTNZ_Immutable
+ VTNZ_Immutable
+ v4.7.2
+ 512
+ true
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+