Last update 03.10.2024
1.1 A tour of C Sharp
1.2 Program structure
1.3 Main function and command line arguments
1.4 Top level statements
1. Write a program which reads n number from the console and prints their sum.
2. Write a program which given the coefficients a, b and c, solves the following equation: ax² + bx + c = 0 and displays the results in the console, if they exist.
3. Write a program which reads n students and stores them in an array. The program should print the student with the highest average grade. The student class should have the following structure:
Student:
2.1 Types
2.2 Namespaces
2.3 Classes
2.4 Structs
2.5 Records
2.6 Interfaces
2.7 Generics
2.8 Anonymous types
2.9 Strings
Write a program which manages the accounts of a bank.
A bank has the following structure:
Bank:
Hint: You can define an additional private method GetAccount(string iban) to find an account with a certain iban.
3.1 Method parameters
3.2 Combinations of parameter type and argument mode
3.3 Safe context of references and values
3.4 Reference parameters
3.5 params modifier
1. Implement a static method, which takes two integers as ref parameters and swaps them.
2. Implement a static method in the Program class, which takes two Coords and returns the middle of the segment defined by the two Coords. Coord is a struct with the following structure:
public struct Coords
{
public float X { get; set; }
public float Y { get; set; }
public Coords(float x, float y)
{
X = x;
Y = y;
}
public override string ToString()
{
return $"({X}, {Y})";
}
}
3. Implement a class Account, which has name and balance properties (initialized by the constructor), and a method Withdraw which allows withdrawal of funds. The method takes a parameter specifying the withdrawal amount and an out parameter in which it returns the remaining balance. If the full amount can be withdrawn, the method returns true. If the amount cannot be withdrawn, the method returns false. The method will have the following signature:
public bool Withdraw(double amount, out double remainingBalance)
4.1 Object-oriented programming
4.2 Objects
4.3 Inheritance
4.4 Polymorphism
Create a class RealEstateAgency, which manages various properties. The property must be implemented using the following class diagram:
Each class in the hierarchy must contain the corresponding properties shown in the above diagram, and override the ToString() method accordingly.
Note: TotalArea property will calculate the sum between IndoorArea and OutdoorArea The RealEstateAgency class will contain a list of properties. It will have the following methods:
5.1 Arrays
5.2 Single dimension arrays
5.3 Multidimensional arrays
5.4 Jagged arrays
5.5 Implicitly types arrays
5.6 Collections
5.7 Iterators
1. Implement a static method RemoveAt, which takes an array, the array's length, and an index. The method removes the element at the given index from the array.
public static void RemoveAt(int[] array, ref int length, int n)
2. Implement a static method which takes two Lists
3. Implement a generic Stack<T> collection using a List<T>. The collection must have the following methods:
public static List Intersection(List l1, List l2)
public class Stack
6.1 Delegates
6.2 Using delegates
6.3 Delegates with named vs anonymous methods
6.4 Combining delegates. Multicast delegates
6.5 Declare, instantiate and use delegates
1. Implement a function named Filter, which takes a boolean functions as a delegate and a list and returns a new list containing the elements which satisfy the condition.
public static List<int> Filter(MyDelegate condition, List<int> list)
2. Implement a static method FGX, which takes 2 delegates as parameters and a float x and returns the composite value of the two given functions.
public static float FGX(MyDelegate del1, MyDelegate del2, float x)
Test your implementation using the following functions:
public static float f(float x)
{
return x * 3
}
public static float g(float x)
{
return x - 2
}
7.1 Events
7.2 Subscribing to and unsubscribing from events
7.3 Handle and raise events
7.4 Raising base class events in derived classes
7.5 Implementing interface events
7.6 Implementing custom event accessors
Create a project with 3 classes: InputReader, CharListener, ComplexListener.
8.1 Asynchronous programming with async and await
8.2 Asynchronous programming scenarios
8.3 Task asynchronous programming model
8.4 Async return types
8.5 Cancel a list of tasks
8.6 Cancel async tasks after a period of time
8.7 Process asynchronous tasks as they complete
8.8 Asynchronous file access
Create a Tamagotchi game. Each Tamagotchi pet needs to be fed regularly or they will starve. If you overfeed Tamagotchi they will also die. The goal of the game is to keep them alive for as long as you can.
The following classes will be required:
The constructor receive the name, starting food, hunger rate, key and an InputReader. After setting the properties, it must also subscribe to the OnKeyPressed event from InputReader with a method HandleKeyPressed. This method will feed the Tamagotchi with 5 food each time the given key is pressed. If you overfeed him (Food > 20) he will die.
An async method Run will be used to simulate the life of the Tamagotchi. This method must continue running while the Tamagotchi is alive. After every HungerRate miliseconds, an amount of 3 will be deducted from Food. If the Food reaches 0 or is greater than 20 the Tamagotchi will die (from starving or being overfed). After deducting the amount of food, the status of the Tamagotchi will be displayed.
A ToString() method will be used to display the status of the Tamagotchi. The following messages should be displayed depending on the Alive status:
Name + "is alive and well. Remaining food: " + Food;
Name + "is dead :("
Name + "is alive and well. Remaining food: " + Food;
9.1 Working with LINQ
9.2 Language Integrated Query (LINQ)
9.3 Introduction to LINQ Queries in C#
9.4 Standard Query Operators Overview
9.5 Write C# LINQ queries to query data
Create an app used for storing and searching for game titles. The following two classes will be required:
Game - this class will store the following properties:
The properties will be set using the constructor. A ToString() method will be used for displaying.
Store - this class will contain a list of available games. The following methods will be available:
All queries will be implemented using Linq. Instructions like for, while, do while will not be accepted.