Compare commits

...

19 Commits

Author SHA1 Message Date
Jason Zhu 237b8fc391 Finished Solution, Throwing & Catching Exceptions, repo at 9f4de32 2021-02-22 00:56:24 +00:00
Jason Zhu 615d267706 Finished Challenge: Taking User Input from Console; By myself 2021-02-22 00:12:35 +00:00
Jason Zhu 41ca2586dc Finished Pattern Matching with switch 2021-02-19 04:33:27 +00:00
Jason Zhu dd47f5cf72 Finished Switching with the swtich Statement 2021-02-19 03:54:21 +00:00
Jason Zhu 009cdc3919 Looping with for, foreach, do, while 2021-02-19 03:13:57 +00:00
Jason Zhu 6c7ba8624f Finished Looking For Reference Types & Value Types & The Special Case of String in .NET 2021-02-19 01:07:25 +00:00
Jason Zhu 8ce65cb61e Finished Passing Parameters by Reference 2021-02-19 00:30:31 +00:00
Jason Zhu 6f9f69b55f Finished Testing Object References & Referencing Different Objects 2021-02-18 01:41:40 +00:00
Jason Zhu b6387e0e8c Finished Testing Your Code, Refactoring for Testability 2021-02-17 12:33:05 +00:00
Jason Zhu 41bf0f3824 Finished Referencing Projects and Packages 2021-02-17 02:30:04 +00:00
Jason Zhu c36b3f5caf Added first assertion 2021-02-17 00:45:17 +00:00
Jason Zhu dfdcdd1281 Creating a Unit Test Project 2021-02-17 00:14:18 +00:00
Jason Zhu 0626a832d3 Encapsulate all methods within Book class 2021-02-16 22:34:31 +00:00
Jason Zhu 6d919686df Created Book.cs for class creation 2021-02-16 22:27:58 +00:00
Jason Zhu bafaa1b11e Finished Module 2. Learning the C# Syntax 2021-02-16 04:07:37 +00:00
Jason Zhu 3a84b1d059 Added README for GradeBook 2021-02-16 03:42:52 +00:00
Jason Zhu 248b18cae8 Created foreach loop 2021-02-16 03:42:26 +00:00
Jason Zhu bf10077762 Finished Module 1. Introduction C# and .NET 2021-02-16 02:47:23 +00:00
Jason Zhu cb4c868686 Added devcontainer file, .gitignore and modified README 2021-02-15 22:20:53 +00:00
16 changed files with 1316 additions and 2 deletions

View File

@ -0,0 +1,23 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.158.0/containers/dotnet/.devcontainer/base.Dockerfile
# [Choice] .NET version: 5.0, 3.1, 2.1
ARG VARIANT="5.0"
FROM mcr.microsoft.com/vscode/devcontainers/dotnetcore:0-${VARIANT}
# [Option] Install Node.js
ARG INSTALL_NODE="true"
ARG NODE_VERSION="lts/*"
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
# [Option] Install Azure CLI
ARG INSTALL_AZURE_CLI="false"
COPY library-scripts/azcli-debian.sh /tmp/library-scripts/
RUN if [ "$INSTALL_AZURE_CLI" = "true" ]; then bash /tmp/library-scripts/azcli-debian.sh; fi \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends tree
# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

View File

@ -0,0 +1,58 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.158.0/containers/dotnet
{
"name": "C# (.NET)",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update 'VARIANT' to pick a .NET Core version: 2.1, 3.1, 5.0
"VARIANT": "5.0",
// Options
"INSTALL_NODE": "true",
"NODE_VERSION": "lts/*",
"INSTALL_AZURE_CLI": "false"
}
},
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-dotnettools.csharp"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [5000, 5001],
// [Optional] To reuse of your local HTTPS dev cert:
//
// 1. Export it locally using this command:
// * Windows PowerShell:
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "$env:USERPROFILE/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
// * macOS/Linux terminal:
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "${HOME}/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
//
// 2. Uncomment these 'remoteEnv' lines:
// "remoteEnv": {
// "ASPNETCORE_Kestrel__Certificates__Default__Password": "SecurePwdGoesHere",
// "ASPNETCORE_Kestrel__Certificates__Default__Path": "/home/vscode/.aspnet/https/aspnetapp.pfx",
// },
//
// 3. Do one of the following depending on your scenario:
// * When using GitHub Codespaces and/or Remote - Containers:
// 1. Start the container
// 2. Drag ~/.aspnet/https/aspnetapp.pfx into the root of the file explorer
// 3. Open a terminal in VS Code and run "mkdir -p /home/vscode/.aspnet/https && mv aspnetapp.pfx /home/vscode/.aspnet/https"
//
// * If only using Remote - Containers with a local container, uncomment this line instead:
// "mounts": [ "source=${env:HOME}${env:USERPROFILE}/.aspnet/https,target=/home/vscode/.aspnet/https,type=bind" ],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "dotnet restore",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}

View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
#
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/master/script-library/docs/azcli.md
#
# Syntax: ./azcli-debian.sh
set -e
if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi
export DEBIAN_FRONTEND=noninteractive
# Install curl, apt-transport-https, lsb-release, or gpg if missing
if ! dpkg -s apt-transport-https curl ca-certificates lsb-release > /dev/null 2>&1 || ! type gpg > /dev/null 2>&1; then
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
apt-get update
fi
apt-get -y install --no-install-recommends apt-transport-https curl ca-certificates lsb-release gnupg2
fi
# Install the Azure CLI
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/azure-cli.list
curl -sL https://packages.microsoft.com/keys/microsoft.asc | (OUT=$(apt-key add - 2>&1) || echo $OUT)
apt-get update
apt-get install -y azure-cli
echo "Done!"

738
.gitignore vendored 100644
View File

@ -0,0 +1,738 @@
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
# Created by https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,macos,linux,executable,csharp,aspnetcore,visualstudio
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,visualstudiocode,macos,linux,executable,csharp,aspnetcore,visualstudio
### ASPNETCore ###
## 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/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# 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
project.fragment.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
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# 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
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# 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 database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# 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
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# 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/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# 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/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/
### Csharp ###
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
# User-specific files (MonoDevelop/Xamarin Studio)
# Mono auto generated files
mono_crash.*
# Build results
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
# Uncomment if you have tasks that create the project's static files in wwwroot
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
# NUnit
nunit-*.xml
# Build Results of an ATL Project
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_h.h
*.iobj
*.ipdb
*_wpftmp.csproj
# Chutzpah Test files
# Visual C++ cache files
# Visual Studio profiler
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
# Guidance Automation Toolkit
# ReSharper is a .NET coding add-in
# TeamCity is a build add-in
# DotCover is a Code Coverage Tool
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]
# Visual Studio code coverage results
# NCrunch
# MightyMoose
# Web workbench (sass)
# Installshield output folder
# DocProject is a documentation generator add-in
# Click-Once directory
# Publish Web Output
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
# NuGet Packages
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
# Microsoft Azure Build Output
# Microsoft Azure Emulator
# Windows Store app package directories and files
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
# RIA/Silverlight projects
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.ndf
# Business Intelligence projects
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
# GhostDoc plugin setting file
# Node.js Tools for Visual Studio
# Visual Studio 6 build log
# Visual Studio 6 workspace options file
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
# Paket dependency manager
# FAKE - F# Make
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
### Executable ###
*.app
*.bat
*.cgi
*.com
*.exe
*.gadget
*.jar
*.pif
*.vb
*.wsf
### Linux ###
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### VisualStudioCode ###
.vscode/*
!.vscode/tasks.json
!.vscode/launch.json
*.code-workspace
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
### VisualStudio ###
# User-specific files
# User-specific files (MonoDevelop/Xamarin Studio)
# Mono auto generated files
# Build results
# Visual Studio 2015/2017 cache/options directory
# Uncomment if you have tasks that create the project's static files in wwwroot
# Visual Studio 2017 auto generated files
# MSTest test Results
# NUnit
# Build Results of an ATL Project
# Benchmark Results
# .NET Core
# StyleCop
# Files built by Visual Studio
# Chutzpah Test files
# Visual C++ cache files
# Visual Studio profiler
# Visual Studio Trace Files
# TFS 2012 Local Workspace
# Guidance Automation Toolkit
# ReSharper is a .NET coding add-in
# TeamCity is a build add-in
# DotCover is a Code Coverage Tool
# AxoCover is a Code Coverage Tool
# Coverlet is a free, cross platform Code Coverage Tool
# Visual Studio code coverage results
# NCrunch
# MightyMoose
# Web workbench (sass)
# Installshield output folder
# DocProject is a documentation generator add-in
# Click-Once directory
# Publish Web Output
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
# NuGet Packages
# NuGet Symbol Packages
# The packages folder can be ignored because of Package Restore
# except build/, which is used as an MSBuild target.
# Uncomment if necessary however generally it will be regenerated when needed
# NuGet v3's project.json files produces more ignorable files
# Microsoft Azure Build Output
# Microsoft Azure Emulator
# Windows Store app package directories and files
# Visual Studio cache files
# files ending in .cache can be ignored
# but keep track of directories ending in .cache
# Others
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
# RIA/Silverlight projects
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
# SQL Server files
# Business Intelligence projects
# Microsoft Fakes
# GhostDoc plugin setting file
# Node.js Tools for Visual Studio
# Visual Studio 6 build log
# Visual Studio 6 workspace options file
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
# Visual Studio LightSwitch build output
# Paket dependency manager
# FAKE - F# Make
# CodeRush personal settings
# Python Tools for Visual Studio (PTVS)
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
# Telerik's JustMock configuration file
# BizTalk build output
# OpenCover UI analysis results
# Azure Stream Analytics local run output
# MSBuild Binary and Structured Log
# NVidia Nsight GPU debugger configuration file
# MFractors (Xamarin productivity tool) working folder
# Local History for Visual Studio
# BeatPulse healthcheck temp database
# Backup folder for Package Reference Convert tool in Visual Studio 2017
# Ionide (cross platform F# VS Code tools) working folder
# End of https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,macos,linux,executable,csharp,aspnetcore,visualstudio
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

30
.vscode/launch.json vendored 100644
View File

@ -0,0 +1,30 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"OS-COMMENT1": "Use IntelliSense to find out which attributes exist for C# debugging",
"OS-COMMENT2": "Use hover for the description of the existing attributes",
"OS-COMMENT3": "For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md",
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"OS-COMMENT4": "If you have changed target frameworks, make sure to update the program path.",
"program": "${workspaceFolder}/gradebook/src/GradeBook/bin/Debug/net5.0/GradeBook.dll",
"args": [],
"cwd": "${workspaceFolder}/gradebook/src/GradeBook",
"OS-COMMENT5": "For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}

42
.vscode/tasks.json vendored 100644
View File

@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/gradebook/src/GradeBook/GradeBook.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/gradebook/src/GradeBook/GradeBook.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/gradebook/src/GradeBook/GradeBook.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@ -1,3 +1,3 @@
# pluralsight-dotnet-paths # pluralsight-dotnet-paths
This is a repository for learning everything about .NET from pluralsight. Including multiple learning Paths This is a repository for learning everything about .NET from pluralsight. Including multiple learning Paths

View File

@ -0,0 +1,7 @@
# GradeBook
Requirement from PM:
> We need an electronic grade book to read the scores of an individual student and then compute some simple statistics from the scores.
> The grades are entered as floating point numbers from 0 to 100, and the statistics show us the highest grade, the lowest grade, and the average grade.

View File

@ -0,0 +1,56 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{41D689B9-3B52-432B-97EF-63FB665C1AA7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GradeBook", "src\GradeBook\GradeBook.csproj", "{B67A3D2F-4755-46E6-960C-8746BADB002C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C32AB033-6E6D-4451-9194-0F6933BC383D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GradeBook.Tests", "test\GradeBook.Tests\GradeBook.Tests.csproj", "{203083CF-9050-48AC-87CC-53AF6F8F79BE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B67A3D2F-4755-46E6-960C-8746BADB002C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B67A3D2F-4755-46E6-960C-8746BADB002C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B67A3D2F-4755-46E6-960C-8746BADB002C}.Debug|x64.ActiveCfg = Debug|Any CPU
{B67A3D2F-4755-46E6-960C-8746BADB002C}.Debug|x64.Build.0 = Debug|Any CPU
{B67A3D2F-4755-46E6-960C-8746BADB002C}.Debug|x86.ActiveCfg = Debug|Any CPU
{B67A3D2F-4755-46E6-960C-8746BADB002C}.Debug|x86.Build.0 = Debug|Any CPU
{B67A3D2F-4755-46E6-960C-8746BADB002C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B67A3D2F-4755-46E6-960C-8746BADB002C}.Release|Any CPU.Build.0 = Release|Any CPU
{B67A3D2F-4755-46E6-960C-8746BADB002C}.Release|x64.ActiveCfg = Release|Any CPU
{B67A3D2F-4755-46E6-960C-8746BADB002C}.Release|x64.Build.0 = Release|Any CPU
{B67A3D2F-4755-46E6-960C-8746BADB002C}.Release|x86.ActiveCfg = Release|Any CPU
{B67A3D2F-4755-46E6-960C-8746BADB002C}.Release|x86.Build.0 = Release|Any CPU
{203083CF-9050-48AC-87CC-53AF6F8F79BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{203083CF-9050-48AC-87CC-53AF6F8F79BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{203083CF-9050-48AC-87CC-53AF6F8F79BE}.Debug|x64.ActiveCfg = Debug|Any CPU
{203083CF-9050-48AC-87CC-53AF6F8F79BE}.Debug|x64.Build.0 = Debug|Any CPU
{203083CF-9050-48AC-87CC-53AF6F8F79BE}.Debug|x86.ActiveCfg = Debug|Any CPU
{203083CF-9050-48AC-87CC-53AF6F8F79BE}.Debug|x86.Build.0 = Debug|Any CPU
{203083CF-9050-48AC-87CC-53AF6F8F79BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{203083CF-9050-48AC-87CC-53AF6F8F79BE}.Release|Any CPU.Build.0 = Release|Any CPU
{203083CF-9050-48AC-87CC-53AF6F8F79BE}.Release|x64.ActiveCfg = Release|Any CPU
{203083CF-9050-48AC-87CC-53AF6F8F79BE}.Release|x64.Build.0 = Release|Any CPU
{203083CF-9050-48AC-87CC-53AF6F8F79BE}.Release|x86.ActiveCfg = Release|Any CPU
{203083CF-9050-48AC-87CC-53AF6F8F79BE}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B67A3D2F-4755-46E6-960C-8746BADB002C} = {41D689B9-3B52-432B-97EF-63FB665C1AA7}
{203083CF-9050-48AC-87CC-53AF6F8F79BE} = {C32AB033-6E6D-4451-9194-0F6933BC383D}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
namespace GradeBook
{
public class Book
{
private List<double> grades;
public string Name;
public Book(string name)
{
Name = name;
grades = new List<double>();
}
public void AddGrade(double grade)
{
if (grade <= 100 && grade >= 0)
{
this.grades.Add(grade);
} else
{
throw new ArgumentException($"Invalid {nameof(grade)}");
}
}
public void AddLetterGrade(char letter)
{
switch (letter)
{
case 'A':
AddGrade(90);
break;
case 'B':
AddGrade(80);
break;
case 'C':
AddGrade(70);
break;
default:
AddGrade(0);
break;
}
}
public Statistics GetStatistics()
{
var result = new Statistics();
result.Average = 0.0;
result.highGrade = double.MinValue;
result.lowGrade = double.MaxValue;
foreach (var grade in this.grades)
{
result.lowGrade = Math.Min(grade, result.lowGrade);
result.highGrade = Math.Max(grade, result.highGrade);
result.Average += grade;
}
result.Average /= grades.Count;
switch (result.Average)
{
case var d when d >= 90.0:
result.Letter = 'A';
break;
case var d when d >= 80.0:
result.Letter = 'B';
break;
case var d when d >= 70.0:
result.Letter = 'C';
break;
case var d when d >= 60.0:
result.Letter = 'D';
break;
default:
result.Letter = 'F';
break;
}
return result;
}
}
}

View File

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
namespace GradeBook
{
class Program
{
static void Main(string[] args)
{
// var book = new Book("Scott's Grade Book");
// book.AddGrade(89.1);
// book.AddGrade(90.5);
// book.AddGrade(87.2);
var book = new Book("Jason's Grade Book");
string input;
while (true)
{
Console.WriteLine("Give input: ");
input = Console.ReadLine();
if (input == "Q" || input == "q")
{
Console.WriteLine("Receiving termination signal; Termiate program");
break;
} else
{
try
{
Console.WriteLine($"Received: {input}");
book.AddGrade(Convert.ToDouble(input));
}
catch (ArgumentException ex)
{
Console.WriteLine(ex.Message);
}
catch (FormatException ex)
{
Console.WriteLine(ex.Message);
}
finally
{
// Will always run for all catch scenario
Console.WriteLine("Always Done");
}
}
}
var stats = book.GetStatistics();
Console.WriteLine($"The lowest grade is {stats.lowGrade}");
Console.WriteLine($"The highesst grade is {stats.highGrade}");
Console.WriteLine($"The average grade is {stats.Average:N1}");
}
}
}

View File

@ -0,0 +1,10 @@
namespace GradeBook
{
public class Statistics
{
public double Average;
public double highGrade;
public double lowGrade;
public char Letter;
}
}

View File

@ -0,0 +1,27 @@
using System;
using Xunit;
namespace GradeBook.Tests
{
public class BookTests
{
[Fact]
public void BookCalculateAnAverageGrade()
{
// arrange
var book = new Book("");
book.AddGrade(89.1);
book.AddGrade(90.5);
book.AddGrade(77.3);
// act
var result = book.GetStatistics();
// assert
Assert.Equal(85.6, result.Average, 1);
Assert.Equal(90.5, result.highGrade);
Assert.Equal(77.3, result.lowGrade);
Assert.Equal('B', result.Letter);
}
}
}

View File

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\GradeBook\GradeBook.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,113 @@
using System;
using Xunit;
namespace GradeBook.Tests
{
using GradeBook;
public class TypeTests
{
[Fact]
public void ValueTypesAlsoPassByValue()
{
var x = GetInt();
Assert.Equal(3,x);
SetInt(ref x);
Assert.Equal(42, x);
}
private void SetInt(ref int x)
{
x = 42;
}
private int GetInt()
{
return 3;
}
[Fact]
public void StringsBehaveLikeValueTypes()
{
string name = "Jason";
MakeUppserCase(name); // try to change String like a reference
Assert.Equal("Jason", name); // ToUpper does not work on String, although it's reference. It's copied as value
}
private void MakeUppserCase(string arg)
{
arg.ToUpper();
}
[Fact]
public void CSharpCanPassByReference()
{
var book1 = GetBook("Book1");
GetBookSetName(ref book1, "New Name");
Assert.Equal(book1.Name, "New Name");
}
private void GetBookSetName(ref Book book, string name)
{
book = new Book(name);
book.Name = name;
}
[Fact]
public void CSharpIsPassByValue()
{
var book1 = GetBook("Book1");
GetBookSetName(book1, "New Name");
Assert.Equal(book1.Name, "Book1");
}
private void GetBookSetName(Book book, string name)
{
book = new Book(name);
book.Name = name;
}
[Fact]
public void CanSetNameFromReference()
{
var book1 = GetBook("Book1");
SetName(book1, "New Name");
Assert.Equal(book1.Name, "New Name");
}
private void SetName(Book book, string name)
{
book.Name = name;
}
[Fact]
public void GetBookReturnsDifferentObjects()
{
var book1 = GetBook("Book1");
var book2 = GetBook("Book2");
Assert.Equal("Book1", book1.Name);
Assert.Equal("Book2", book2.Name);
}
[Fact]
public void TwoVarsCanReferenceSameObject()
{
var book1 = GetBook("Book1");
var book2 = book1;
Assert.Equal(book2.Name, book1.Name);
Assert.True(Object.ReferenceEquals(book1, book2));
}
private Book GetBook(string name)
{
return new Book(name);
}
}
}