Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Commit

Permalink
code-a-long for unit 1 exceptions chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
CFreyLC committed May 17, 2021
1 parent b1eddcb commit 0764228
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 1 deletion.
2 changes: 2 additions & 0 deletions TemperatureExceptions/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;

//Book example for the Unit 2 C# program

namespace TemperatureExceptions
{
class Program
Expand Down
18 changes: 18 additions & 0 deletions Unit1-TempExceptions/Unit1-TempExceptions/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;

//Book examples for the Unit 1 C# Program

namespace Unit1_TempExceptions
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter a Fahrenheit temperature value");
string inputValue = Console.ReadLine();
double inputTemp = Double.Parse(inputValue);

Temperature userTemp = new Temperature(inputTemp);
}
}
}
20 changes: 20 additions & 0 deletions Unit1-TempExceptions/Unit1-TempExceptions/Temperature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
namespace Unit1_TempExceptions
{
public class Temperature
{
public static double absoluteZero = -459.67;

public Temperature(double fahrenheit)
{
if (fahrenheit < absoluteZero)
{
throw new ArgumentOutOfRangeException("Value is below absolute zero.");
}
else
{
Console.WriteLine("You entered " + fahrenheit + " degrees F.");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>Unit1_TempExceptions</RootNamespace>
</PropertyGroup>

</Project>
10 changes: 10 additions & 0 deletions Unit1-TempExceptions/Unit1-TempExceptions999.mdproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ItemType>GenericProject</ItemType>
<ProjectGuid>{3F143C80-67FF-4BE6-9DDB-4031A4D9243B}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Default|AnyCPU' ">
<OutputPath>.\</OutputPath>
</PropertyGroup>
</Project>
18 changes: 18 additions & 0 deletions csharp-web-dev-lsn9exceptions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,37 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharp-web-dev-lsn9exceptio
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemperatureExceptions", "TemperatureExceptions\TemperatureExceptions.csproj", "{54D0743B-BE90-4785-9757-181B4BED9BBB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "New Folder", "New Folder", "{8FAE07CE-0D3C-42FB-8861-4BA96F38D65B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unit1-TempExceptions", "Unit1-TempExceptions\Unit1-TempExceptions\Unit1-TempExceptions.csproj", "{172DC0C4-1713-4A5A-B4CA-446D61F5063D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Default|Any CPU = Default|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{487C4423-B09D-41A7-B8CE-B3B218FA8CB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{487C4423-B09D-41A7-B8CE-B3B218FA8CB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{487C4423-B09D-41A7-B8CE-B3B218FA8CB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{487C4423-B09D-41A7-B8CE-B3B218FA8CB9}.Release|Any CPU.Build.0 = Release|Any CPU
{487C4423-B09D-41A7-B8CE-B3B218FA8CB9}.Default|Any CPU.ActiveCfg = Debug|Any CPU
{487C4423-B09D-41A7-B8CE-B3B218FA8CB9}.Default|Any CPU.Build.0 = Debug|Any CPU
{54D0743B-BE90-4785-9757-181B4BED9BBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{54D0743B-BE90-4785-9757-181B4BED9BBB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{54D0743B-BE90-4785-9757-181B4BED9BBB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{54D0743B-BE90-4785-9757-181B4BED9BBB}.Release|Any CPU.Build.0 = Release|Any CPU
{54D0743B-BE90-4785-9757-181B4BED9BBB}.Default|Any CPU.ActiveCfg = Debug|Any CPU
{54D0743B-BE90-4785-9757-181B4BED9BBB}.Default|Any CPU.Build.0 = Debug|Any CPU
{172DC0C4-1713-4A5A-B4CA-446D61F5063D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{172DC0C4-1713-4A5A-B4CA-446D61F5063D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{172DC0C4-1713-4A5A-B4CA-446D61F5063D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{172DC0C4-1713-4A5A-B4CA-446D61F5063D}.Release|Any CPU.Build.0 = Release|Any CPU
{172DC0C4-1713-4A5A-B4CA-446D61F5063D}.Default|Any CPU.ActiveCfg = Debug|Any CPU
{172DC0C4-1713-4A5A-B4CA-446D61F5063D}.Default|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
BaseDirectory = Unit1-TempExceptions
EndGlobalSection
EndGlobal
5 changes: 4 additions & 1 deletion csharp-web-dev-lsn9exceptions/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;

//Exercises for the Exceptions Chapter

namespace csharp_web_dev_lsn9exceptions
{
class Program
{
/*
static double Divide(double x, double y)
{
// Write your code here!
Expand All @@ -14,7 +17,7 @@ static int CheckFileExtension(string fileName)
{
// Write your code here!
}

*/

static void Main(string[] args)
{
Expand Down

0 comments on commit 0764228

Please sign in to comment.