/csharp_practical

Exercises and challenges for the C# course

Primary LanguageC#

CSharp Practical

This repository belongs to: YOUR_NAME_HERE

This repository contains the challenges that accompany the C# course at VIVES University of Applied Sciences at Bruges which can be found at http://base-to-ace.netlify.com.

Each chapter contains a number of challenges. Some may come with solutions other may not. Most of them are accompanied by Unit Tests.

All challenges contain at least a README.md describing the task at hand. Most already contain a Visual Studio solution to start from.

Starting as a Student

To get started you will first need to get a copy of this repository. Follow the steps below to get your own personal copy. This only needs to be done once.

  1. Get the GitHub classroom invitation link from Toledo.
  2. The first time you will need to allow GitHub Classroom access to your GitHub account. Click the Authorize github button.

Authorize GitHub Classroom

  1. Make sure to select your name from the roster. If your name is not present yet then you can click the Skip to the next step for now. But please inform your teacher in that case.

Select name from Roster

  1. Now you can accept the assignment and wait for your own personal copy to be created (can take up to several minutes - please be patient)

  2. Open the GitHub page of your repository

  3. Copy the ssh clone-url (green button) that looks like git@github.com:vives-intro-to-programming-2022-2023/csharp-practical-<username>.git

  4. Traverse to a local directory on your system where you wish to clone the repo using Windows Explorer. Open PowerShell in that location by holding down Shift and right clicking the directory. Next select Open PowerShell window here from the context menu.

    Please don't choose a destination directory that is nested very deeply. The structure of this repo introduces quite a lot of subdirectories and might give problems towards maximum path length in Windows.

    Opening PowerShell in directory

  5. Issue the git clone command followed by the url you copied (right click or Ctrl + V to paste).

git clone <place-ssh-url-here>

You should get a similar output:

Cloning into 'csharp-practical-NicoDeWitte'...
Warning: Permanently added the RSA host key for IP address '140.82.121.4' to the list of known hosts.
remote: Enumerating objects: 1241, done.
remote: Counting objects: 100% (1241/1241), done.
remote: Compressing objects: 100% (625/625), done.
remote: Total 1241 (delta 546), reused 1241 (delta 546), pack-reused 0
Receiving objects: 100% (1241/1241), 602.71 KiB | 1.77 MiB/s, done.
Resolving deltas: 100% (546/546), done.

Now you should have your local copy of the repository.

All git commands in other sections should always be executed inside of the project dir called csharp-practical-<username>.

Committing Changes

Changes can be committed and pushed back to GitHub using the terminal.

Traverse to your local csharp-practical-<username> directory and open a PowerShell window by holding down Shift and right clicking the directory. Next select Open PowerShell window here from the context menu, as done previously in section Starting as a Student.

  1. Add all changed files using the command: git add .

  2. Commit the files and add a message: git commit -m "My message goes here"

  3. Push your changes to GitHub: git push origin master

    Committing and pushing via PowerShell

  4. To make sure all is well, you can always issue the command git status, even in between other commands.

You can also navigate to your GitHub page of this repo and check if all went well.

Make it a habit of committing and pushing regularly. At least after solving each assignment.

Also checkout the shortened version of these steps for everyday use.

Pulling the Latest Updates

To pull the latest updates you will first need to add the original repo on which this one was based. This only needs to be done once for every cloned instance:

git remote add base git@github.com:vives-intro-to-programming-2022-2023/csharp-practical.git

base is the name of remote repo. Now you should see two remotes when issuing the command git remote -v. For example:

base     git@github.com:vives-intro-to-programming-2022-2023/csharp-practical.git (fetch)
base     git@github.com:vives-intro-to-programming-2022-2023/csharp-practical.git (push)
origin  git@github.com:vives-intro-to-programming-2022-2023/csharp-practical-NicoDeWitte.git (fetch)
origin  git@github.com:vives-intro-to-programming-2022-2023/csharp-practical-NicoDeWitte.git (push)

Now every time you wish to pull updates you need to follow these steps:

  1. First make sure that you have no local changes. This can be seen by executing git status. It should state nothing to commit, working tree clean. If not, you first need to add and commit the changes (see section Committing Changes).
  2. Now issue the command git pull base master --allow-unrelated-histories to pull the latest changes.

Pulling Changes

Make sure you have no conflicts before committing everything.

Also checkout the shortened version of these steps for everyday use.

Overview

Please indicate which challenges you have finished by placing a ✔️ emoji in the finished column. These were found at https://emojipedia.org.

xUnit Tests

Unit Tests allow code to be tested automatically for correctness.

Some challenges might be accompanied by these tests (👍 in Unit Tests? column).

Open the Test Explorer overview in Visual Studio by navigating to Test => Windows => Test Explorer.

Hit the first green arrow at the top left (Run All):

Run All Tests

Normally the tests will always fail in the beginning.

Failing Tests

If the challenge is solved correctly, all tests should pass.

Succeeding Tests

xUnit Framework not Found

If you get an error stating the the xUnit Framework cannot be found, you should check the NuGet package manager sources.

Traverse to Tools => NuGet Package Manager => Package Manager Settings. Next select the Package Sources entry as option (left side). It should contain the nuget.org package source as shown in the next screenshot:

nuget.org source

If it does not exists, add it with the following settings:

  • Name: nuget.org
  • Source: https://api.nuget.org/v3/index.json

You may need to restart Visual Studio.

Introduction to Programming

Chapter 01 - Introduction to Computer Programming

Finished Challenge Difficulty Description
Making a Sandwich Easy Document the process of making a ham and cheese sandwich.
Programming Languages Medium Search the Internet for some programming languages.
Processor Architecture Medium Search the Internet for the meaning of a processor architecture.
Biggest Number in a List Hard Document the process of finding the biggest number in a list.

Chapter 02 - Basic Building Blocks

Finished Challenge Difficulty Description
BMI Adult Check Easy Check if user is an adult when calculating the BMI
Personalized BMI Easy Personalize the BMI example with the users name
Smartphones Easy Determine the properties of Smartphones
Cinema Easy Determine the properties of a cinema screening
Circle Circumference Medium Determine the circumference of a circle
Rectangle Area Medium Determine the area of a rectangle
Motorcycles Medium Determine the properties of Motorcycles
Student Grader Medium Output message to user based on his grade
Sum of Numbers Hard Determine the sum of a list of numbers

Chapter 03 - Starting in C#

Finished Challenge Difficulty Description Unit Tests?
Hello World Easy Print a Hello World message
Java Programmer Easy Fix mistake of a Java programmer
Basic Syntax Error Easy Find and fix a small syntax error
Developed By Easy Print message and your name
My First App Medium Create a new VS Project
Need a Break Medium Find and fix two small syntax errors
Personal Details Medium Print out personal details

Chapter 04 - Storing Data

Finished Challenge Difficulty Description Unit Tests?
C# Land Easy Initialize minimum required height variable 👍
Frame Delimiter Medium Initialize start and end of frame delimiter 👍
Marco Polo Medium Output some personal details about Marco Polo 👍
Programming Bugs Hard Output authored message of the day 👍

Chapter 05 - Processing Data

Finished Challenge Difficulty Description Unit Tests?
Rectangle Properties Easy Calculate area and circumference of a rectangle 👍
Pythagoras Easy Implement the Pythagorean theorem 👍
Fundamental Calculus Easy Model a calculator 👍
Pizza Time Medium Divide pizzas among people 👍
Evaluation Medium Determine final score of course 👍
Calculating VAT Medium Calculate taxes on a net value 👍
Circle Properties Hard Show properties of a circle

Chapter 06 - Getting User Data

Finished Challenge Difficulty Description Unit Tests?
Student ID Medium Generate student email and ID 👍
Far From Home Medium Calculate fuel usage for a trip
Time Machine Hard Add hours and minutes to clock 👍

Chapter 07 - Methods

Finished Challenge Difficulty Description Unit Tests?
Hail C Sharp Easy Call a method that outputs statements
Sum and Difference Easy Call and create methods for Addition and Subtraction
Hello Mister Roboto Easy Create a method that outputs a greeting
Toss a Die to Your Witcher Easy Call die throwing method and store result
La Resistance Medium Solve resistor networks
Its all About Timing Hard Converts seconds to Timestamp

Chapter 08 - Making Decisions

Finished Challenge Difficulty Description Unit Tests?
Rectangle Area Easy Determine area of rectangle 👍
Coordinate Plane Easy Determine quadrant of a point in 2D space 👍
LED Series Resistor Easy Determine the series resistor of an LED 👍
Baby Roulette Medium Build a guessing game
Square Roots Medium Determine square roots of integer numbers
Drifting Years Medium Check if given year is a leap year 👍
Biggest Number Medium Biggest number out of 3 👍
ConverterNator Hard Menu Choice of Imperial versus Metric conversions 👍
Number Properties Hard Determine the properties of two numbers

Chapter 09 - Loops

Finished Challenge Difficulty Description Unit Tests?
Up and Down Medium Generate series using for-loops
Roll Em All Medium Throwing Dice
Start to End Medium Summing Series 👍
Fibonacci Sequence Medium Generate the Fibonacci sequence
Higher / Lower Medium Build a higher /lower guessing game
Greatest Common Factor Medium Brute-force the gcf of two numbers 👍
AppleCake Medium AppleCake word game 👍
Series of Squares Medium Check for formula for a series of squares 👍
Number Manipulator Medium Manipulate numbers digit by digit 👍
Child's Play Hard Summation Game
Visual Rectangle Hard Drawing rectangle in the terminal

Chapter 10 - Strings

Finished Challenge Difficulty Description Unit Tests?
Reversal Easy Reverse the characters of a string 👍
Binary Coding Easy Convert binary to decimal 👍
Pattern Builder Easy Shape builder app for console
Text Properties Easy Analyze string for character classes 👍
Holo Gram Easy Check if sentence contains all the letters of the alphabet 👍
Parentheses Checker Medium Check line of code for matching parentheses 👍
Palindrome Medium Determine if a word is a palindrome 👍
Words Everywhere Medium Determine the number of words in a text 👍
How Many Times Medium Find the number of occurrences of a word 👍
Abbreviate This Medium Abbreviate words in a string 👍
Not My Mail Medium Basic validation of email address 👍
Binary Nibble Hard Binary representation of decimal value 👍
Replace Performance Hard Replace substring in text 👍

Chapter 11 - Arrays

Finished Challenge Difficulty Description Unit Tests?
Multiples of Three Easy Generate array with multiples of three 👍
The Sum of All Numbers Easy Calculate sum of array of integers 👍
Absolute Sum Easy Calculate sum of array of absolute values 👍
Parallel Arrays Medium Working with multiple arrays 👍
String to Numbers Medium Convert array of strings to array of integers 👍
Join the Resistance Medium A resistor color band converter
Turn the Tables Medium Multiply arrays with each other 👍
Biggest of them All Medium Determine the biggest number in an array 👍
Time for Change Hard A vending machine simulator

Chapter 23 - Creating and Using Objects

Finished Challenge Difficulty Description Unit Tests?
Point in Space Medium Create class of 2D Point 👍
Round About Medium Create a class for a Circle 👍

Chapter 24 - Defining Custom Classes

Finished Challenge Difficulty Description Unit Tests?
Teach the Teacher Medium Store personal details of teacher 👍
Kings of Nothing Medium Implement a player class for a game 👍
The Paint Factory Medium Calculate how much paint is required for complex surfaces 👍

Chapter 25 - Getters, Setters and Properties

Finished Challenge Difficulty Description Unit Tests?
Super String Theory Medium Add properties and implement string methods 👍
Third Rock from the Sun Hard Calculate properties of the Earth (sphere) 👍

Chapter 26 - Constructors

Finished Challenge Difficulty Description Unit Tests?
I Can Hear Colors Easy Refactor the Color class with properties and constructors 👍
Back to the Future Medium Create a TimeStamp class 👍
Vector from Start to End Medium Create vectors and calculate resulting total vector 👍
Quadratic Medium Solve a quadratic equation
Things are Complex Hard Math with Complex numbers 👍

Chapter 28 - Interfaces

Finished Challenge Difficulty Description Unit Tests?
Generator of Numbers Medium Create an interface for number generators
Total Surface Medium Fix tightly coupled classes

Chapter 50 - Introduction to WPF

Finished Challenge Difficulty Description Unit Tests?
Count Me Up Scotty Medium Create a WPF App for Count Me Up Scotty
Complex Calculator Medium Create a WPF App for Things Are Complex
Hangman Refactored Medium Refactor the hangman game to a library and create a GUI