diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b06e864 --- /dev/null +++ b/.gitignore @@ -0,0 +1,212 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +.vs/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +## TODO: Comment the next line if you want to checkin your +## web deploy settings but do note that will include unencrypted +## passwords +#*.pubxml + +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml diff --git a/TvHRace.sln b/TvHRace.sln new file mode 100644 index 0000000..48ac5f9 --- /dev/null +++ b/TvHRace.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TvHRace", "TvHRace\TvHRace.csproj", "{47611AE8-E0E8-4F0D-83A4-DCBAEE25079A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {47611AE8-E0E8-4F0D-83A4-DCBAEE25079A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47611AE8-E0E8-4F0D-83A4-DCBAEE25079A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47611AE8-E0E8-4F0D-83A4-DCBAEE25079A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47611AE8-E0E8-4F0D-83A4-DCBAEE25079A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/TvHRace/App.config b/TvHRace/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/TvHRace/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/TvHRace/Hare.cs b/TvHRace/Hare.cs new file mode 100644 index 0000000..a1d2fec --- /dev/null +++ b/TvHRace/Hare.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TvHRace +{ + class Hare : Racer + { + + public override void move() + { + Random rnd = new Random(); + int roll = rnd.Next(1, 11); + if (roll <= 2) + Position += 0; + else if (roll > 2 && roll <= 4) + Position += 9; + else if (roll ==5) + Position -= 12; + else if (roll > 5 && roll <= 8) + Position++; + else + Position-=2; + + } + public override void draw() { Console.Write("Hare: "); base.draw(); } + + } +} + diff --git a/TvHRace/Program.cs b/TvHRace/Program.cs new file mode 100644 index 0000000..ab78888 --- /dev/null +++ b/TvHRace/Program.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TvHRace +{ + class Program + { + static void Main(string[] args) + { + + Racer t = new Tortoise(); + Racer h = new Hare(); + while (true) + { + h.initialize(); + t.initialize(); + while (t.Position < 100 && h.Position < 100) + { + + t.move(); + h.move(); + + + Console.Clear(); + string tmp = new string(' ', 30); + Console.WriteLine(tmp + "******* The Race *******"); + + t.draw(); + h.draw(); + + System.Threading.Thread.Sleep(100); + + } + Console.ReadKey(); + } + } + } +} diff --git a/TvHRace/Properties/AssemblyInfo.cs b/TvHRace/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2f7d6f6 --- /dev/null +++ b/TvHRace/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("TvHRace")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TvHRace")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[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("47611ae8-e0e8-4f0d-83a4-dcbaee25079a")] + +// 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/TvHRace/Racer.cs b/TvHRace/Racer.cs new file mode 100644 index 0000000..5a4ddc8 --- /dev/null +++ b/TvHRace/Racer.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TvHRace +{ + abstract class Racer + { + + public Racer() {} + public void initialize() { Position = 0; } + public abstract void move(); + public virtual void draw() { + for (int i = 0; i < Position; i++) + Console.Write("*"); + } + + private int _position = 0; + public int Position { get; protected set; } + } +} diff --git a/TvHRace/Tortoise.cs b/TvHRace/Tortoise.cs new file mode 100644 index 0000000..fec5624 --- /dev/null +++ b/TvHRace/Tortoise.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TvHRace +{ + class Tortoise : Racer + { + + public override void move() { + Random rnd = new Random(); + int roll = rnd.Next(1, 11); + if (roll <= 5) + Position += 3; + else if (roll > 5 && roll <= 7) + Position -= 6; + else + Position++; + + } + public override void draw() { Console.Write("Tortoise: "); base.draw(); Console.WriteLine(); } + + } +} diff --git a/TvHRace/TvHRace.csproj b/TvHRace/TvHRace.csproj new file mode 100644 index 0000000..3646da8 --- /dev/null +++ b/TvHRace/TvHRace.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {47611AE8-E0E8-4F0D-83A4-DCBAEE25079A} + Exe + Properties + TvHRace + TvHRace + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/calculatorAssigment.sln b/calculatorAssigment.sln new file mode 100644 index 0000000..23b49f8 --- /dev/null +++ b/calculatorAssigment.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "calculatorAssigment", "calculatorAssigment\calculatorAssigment.csproj", "{FF53675C-3780-4241-B1DA-78F4A6DA15A2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FF53675C-3780-4241-B1DA-78F4A6DA15A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF53675C-3780-4241-B1DA-78F4A6DA15A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF53675C-3780-4241-B1DA-78F4A6DA15A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF53675C-3780-4241-B1DA-78F4A6DA15A2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/calculatorAssigment/App.config b/calculatorAssigment/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/calculatorAssigment/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/calculatorAssigment/Calculator.cs b/calculatorAssigment/Calculator.cs new file mode 100644 index 0000000..b6e4cf1 --- /dev/null +++ b/calculatorAssigment/Calculator.cs @@ -0,0 +1,137 @@ +/** +@file calculator.cs +@author Chris Arsenault Chris.arsenault06@gmail.com +@version 1.0 + + +@section DESCRIPTION + +calculator program that pulls the left hand and right hand operands and also gets the operator from the user then calculates it and sends it back to the user + +*/ + + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace calculatorAssigment +{ + class Calculator + { + //variables + private double _lhs = 0; + private double _rhs = 0; + private string _operand; + private double _total = 0; + + + public void getCalculation() + { + + + //checks if the user sent a input that can be converted into a double. + //if it cant it keeps it as the default initialisation(0) + Console.Write("Enter left hand number: "); + Double.TryParse((Console.ReadLine()), out _lhs); + + + + //the error checking for the operator is in the calculate method + Console.Write("Enter the operator: "); + _operand = (Console.ReadLine()); + + //if they input factorial it ignores the right hand operand + if (_operand != "!" && _operand != "f" && _operand != "F") + { + + //checks if the user sent a input that can be converted into a double. + //if it cant it keeps it as the default initialisation(0) + Console.Write("Enter right hand number: "); + Double.TryParse((Console.ReadLine()), out _rhs); + + } + + + + } + + public double Calculate() + { + _total = 0; //resets the total incase they do multiple calculations in a single session + + switch (_operand) + { + //addition + case "A": + case "a": + case "+": + _total = _lhs + _rhs; + break; + //subtraction + case "S": + case "s": + case "-": + _total = _lhs - _rhs; + break; + //Multiplication + case "M": + case "m": + case "*": + _total = _lhs * _rhs; + if (_total > 1000000 || _total < -1000000) //so it wont become to big or small + { + Console.WriteLine("overflow"); + _total = 0; + } + break; + //division + case "D": + case "d": + case "/": + if (_rhs != 0) //to avoid division by zero + _total = _lhs / _rhs; + else + Console.WriteLine("div0"); + break; + //exponent + case "E": + case "e": + case "^": + _total = Math.Pow(_lhs, _rhs); + break; + //Factorial + case "F": + case "f": + case "!": + if (_lhs < 0) //makes sure they don't try to factorial a negative number + { + Console.WriteLine("ERROR"); + break; + } + + + _lhs = Convert.ToInt64(_lhs);// converts into a Long + + for (var i = _lhs; i != 0; i--) + _total += _lhs * i; + + _total = Convert.ToDouble(_total); + break; + + + //if the user didnt send in a proper operator + default: + Console.WriteLine("error"); + _total = 0; + break; + + } + + + return _total; + } + } +} diff --git a/calculatorAssigment/Program.cs b/calculatorAssigment/Program.cs new file mode 100644 index 0000000..cf6db60 --- /dev/null +++ b/calculatorAssigment/Program.cs @@ -0,0 +1,40 @@ +/** +@file Program.cs +@author Chris Arsenault Chris.arsenault06@gmail.com +@version 1.0 + + +@section DESCRIPTION + +main file that calls the calulator.cs methods and checks if the user want to continue or not + + +*/ + + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace calculatorAssigment +{ + class Program + { + static void Main(string[] args) + { + + string end = ""; + Calculator calc = new Calculator(); + while (end != "Q" && end != "q") + { + calc.getCalculation(); + Console.WriteLine(calc.Calculate()); + Console.WriteLine(@"Do you want to Quit? 'q' or 'Q' to quit"); //checks for the exit case + end = Console.ReadLine(); + } + + } + } +} diff --git a/calculatorAssigment/Properties/AssemblyInfo.cs b/calculatorAssigment/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c5dfff4 --- /dev/null +++ b/calculatorAssigment/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("calculatorAssigment")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("calculatorAssigment")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[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("ff53675c-3780-4241-b1da-78f4a6da15a2")] + +// 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/calculatorAssigment/calculatorAssigment.csproj b/calculatorAssigment/calculatorAssigment.csproj new file mode 100644 index 0000000..e6419d2 --- /dev/null +++ b/calculatorAssigment/calculatorAssigment.csproj @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + {FF53675C-3780-4241-B1DA-78F4A6DA15A2} + Exe + Properties + calculatorAssigment + calculatorAssigment + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file