Skip to content
35 changes: 20 additions & 15 deletions AppsLab.CSharp.Exercises.sln
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppsLab-033-NuGet", "src\Ap
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppsLab-034-Debug", "src\AppsLab-034-Debug\AppsLab-034-Debug.csproj", "{83C963FD-DC23-46E8-9545-F56197164810}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp2", "ConsoleApp2\ConsoleApp2.csproj", "{18E65813-FB33-4C61-AAA7-8138DE19DE2A}"
EndProject
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Expand Down Expand Up @@ -226,18 +225,6 @@ Global
{A6659FD2-5F11-432B-91B7-C64EAEAF669C}.Release|x64.Build.0 = Release|Any CPU
{A6659FD2-5F11-432B-91B7-C64EAEAF669C}.Release|x86.ActiveCfg = Release|Any CPU
{A6659FD2-5F11-432B-91B7-C64EAEAF669C}.Release|x86.Build.0 = Release|Any CPU
{B141B973-9C0B-4512-B8B4-1237B596A8D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B141B973-9C0B-4512-B8B4-1237B596A8D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B141B973-9C0B-4512-B8B4-1237B596A8D2}.Debug|x64.ActiveCfg = Debug|Any CPU
{B141B973-9C0B-4512-B8B4-1237B596A8D2}.Debug|x64.Build.0 = Debug|Any CPU
{B141B973-9C0B-4512-B8B4-1237B596A8D2}.Debug|x86.ActiveCfg = Debug|Any CPU
{B141B973-9C0B-4512-B8B4-1237B596A8D2}.Debug|x86.Build.0 = Debug|Any CPU
{B141B973-9C0B-4512-B8B4-1237B596A8D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B141B973-9C0B-4512-B8B4-1237B596A8D2}.Release|Any CPU.Build.0 = Release|Any CPU
{B141B973-9C0B-4512-B8B4-1237B596A8D2}.Release|x64.ActiveCfg = Release|Any CPU
{B141B973-9C0B-4512-B8B4-1237B596A8D2}.Release|x64.Build.0 = Release|Any CPU
{B141B973-9C0B-4512-B8B4-1237B596A8D2}.Release|x86.ActiveCfg = Release|Any CPU
{B141B973-9C0B-4512-B8B4-1237B596A8D2}.Release|x86.Build.0 = Release|Any CPU
{FD645D4C-9DC8-4603-A77B-8A4782F175F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD645D4C-9DC8-4603-A77B-8A4782F175F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD645D4C-9DC8-4603-A77B-8A4782F175F4}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -634,6 +621,21 @@ Global
{83C963FD-DC23-46E8-9545-F56197164810}.Release|x64.Build.0 = Release|Any CPU
{83C963FD-DC23-46E8-9545-F56197164810}.Release|x86.ActiveCfg = Release|Any CPU
{83C963FD-DC23-46E8-9545-F56197164810}.Release|x86.Build.0 = Release|Any CPU
{18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Debug|x64.ActiveCfg = Debug|Any CPU
{18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Debug|x64.Build.0 = Debug|Any CPU
{18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Debug|x86.ActiveCfg = Debug|Any CPU
{18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Debug|x86.Build.0 = Debug|Any CPU
{18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|Any CPU.Build.0 = Release|Any CPU
{18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|x64.ActiveCfg = Release|Any CPU
{18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|x64.Build.0 = Release|Any CPU
{18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|x86.ActiveCfg = Release|Any CPU
{18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{57860CA2-0054-465E-BD1E-024FF8D81354} = {56555FB0-B513-49EF-9002-A5AF135EA090}
Expand Down Expand Up @@ -680,4 +682,7 @@ Global
{38FFE1DF-4B49-40C1-9908-51860BCF2D3E} = {56555FB0-B513-49EF-9002-A5AF135EA090}
{83C963FD-DC23-46E8-9545-F56197164810} = {56555FB0-B513-49EF-9002-A5AF135EA090}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0463079C-E8B4-4F31-9B34-80769936C76B}
EndGlobalSection
EndGlobal
10 changes: 10 additions & 0 deletions ConsoleApp1/ConsoleApp1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
10 changes: 10 additions & 0 deletions ConsoleApp2/ConsoleApp2.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
17 changes: 17 additions & 0 deletions ConsoleApp2/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
string[] names = new string[] { "Michal", "Matej", "Alex", "David", "Eva" };
string[,] matrix = new string [ 30, 5 ];
matrix [0, 2] = "Michal";
matrix [1, 2] = "Matej";
matrix [25, 4] = "Alex";
matrix [29, 0] = "David";
for (int i =0; i < 30; i++)
{
for (int j = 0; j < 5; j++)
{
Console.WriteLine(matrix [i, j] + ", ");
}
Console.WriteLine();
}



10 changes: 10 additions & 0 deletions ConsoleApp3/ConsoleApp3.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
17 changes: 17 additions & 0 deletions ConsoleApp3/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
string text = "quarty";
taxt = "iny text";
text += "dalsi text";

int vek = 5;
int vek1 = 10;
vek = 15;
vek += 5;

if (vek > 18)
{
Console.WriteLine("Si dospely");
}
else
{
Console.WriteLine("Som dieta ");
}
10 changes: 10 additions & 0 deletions ConsoleApp4/ConsoleApp4.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
18 changes: 18 additions & 0 deletions ConsoleApp4/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

string text = "quarty";
taxt = "iny text";
text += "dalsi text";

int vek = 5;
int vek1 = 10;
vek = 15;
vek += 5;

if (vek > 18)
{
Console.WriteLine("Si dospely");
}
else
{
Console.WriteLine("Som dieta ");
}
2 changes: 1 addition & 1 deletion src/AppsLab-001-StartHere/Greetings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public class Greetings
/// <returns>A string containing the greeting message.</returns>
public string Hello()
{
return "Hello World!";
return "Hello AppsLab!";
}
}
4 changes: 3 additions & 1 deletion src/AppsLab-002-ConsoleWriteLine/Program.cs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Console.WriteLine("Hello, World!");
int age = 15;
string name = "Matej";
Console.WriteLine($"My name is {name} and I am {age}");
20 changes: 18 additions & 2 deletions src/AppsLab-005-DataTypes/Program.cs
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
int mojeCislo = 15;
string mojeSlovo = "Ahoj, svet!";
bool mojaBoolHodnota = true;
DateTime dnesnyDatum = DateTime.Now;
float myFloat = 5.5f;
int sucet = mojeCislo + 5;
var myVar = "Toto je var string";
const int MaxStudents = 15;

Console.WriteLine(mojeCislo.ToString("000000"));
Console.WriteLine(mojeSlovo);
Console.WriteLine($"Súčet je: {sucet}");
Console.WriteLine($"Dnes je: {dnesnyDatum.ToString("yyyy-MM-dd")}");
Console.WriteLine($"Bool hodnota je: {mojaBoolHodnota}");
Console.WriteLine(myFloat);
Console.WriteLine(myVar);
Console.WriteLine("Maximálny počet študentov v triede je: " + MaxStudents);

8 changes: 6 additions & 2 deletions src/AppsLab-006-Constants/Program.cs
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
const int MaxPoints = 100;
const int MinAgeDriversLicence = 20;
const string WelcomeMessage = "Vitajte v nasej triede";
Console.WriteLine(MaxPoints);
Console.WriteLine(MinAgeDriversLicence);
Console.WriteLine(WelcomeMessage);
14 changes: 7 additions & 7 deletions src/AppsLab-007-Casting/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,54 @@ public class Converter
/// </summary>
public double IntToDouble(int number)
{
throw new NotImplementedException();
return Convert.ToDouble(number);
}

/// <summary>
/// This method converts a double to an integer.
/// </summary>
public int DoubleToInt(double number)
{
throw new NotImplementedException();
return Convert.ToInt32(number);
}

/// <summary>
/// This method converts a string to a double.
/// </summary>
public double StringToDouble(string number)
{
throw new NotImplementedException();
return Convert.ToDouble(number);
}

/// <summary>
/// This method converts a double to a string.
/// </summary>
public string DoubleToString(double number)
{
throw new NotImplementedException();
return Convert.ToString(number);
}

/// <summary>
/// This method converts a string to a boolean.
/// </summary>
public string IntToString(int number)
{
throw new NotImplementedException();
return Convert.ToString(number);
}

/// <summary>
/// This method converts a boolean to a string.
/// </summary>
public bool StringToBool(string boolValue)
{
throw new NotImplementedException();
return Convert.ToBoolean(boolValue);
}

/// <summary>
/// This method converts a boolean to a string.
/// </summary>
public string BoolToString(bool boolValue)
{
throw new NotImplementedException();
return Convert.ToString(boolValue);
}
}
23 changes: 16 additions & 7 deletions src/AppsLab-008-ConsoleReadLine/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
Console.WriteLine("Ako sa voláš?");
string? meno = Console.ReadLine();
Console.WriteLine("Ahoj, " + meno);
Console.WriteLine("Vitaj v kalkulacke");
Console.WriteLine("Zadaj prve cislo: ");
decimal cislo1 = decimal.Parse(Console.ReadLine());
Console.WriteLine("Zadaj druhe cislo: ");
decimal cislo2 = decimal.Parse(Console.ReadLine());
Console.WriteLine("Zadaj operaciu (+,-,*,/,%):");
string operacia = Console.ReadLine();

Console.WriteLine("Koľko máš rokov?");
string vstup = Console.ReadLine() ?? "0";
int vek = int.Parse(vstup);
Console.WriteLine("Máš " + vek + " rokov.");
int vysledok = operacia switch
{
"+" => (int)(cislo1 + cislo2),
"-" => (int)(cislo1 - cislo2),
"*" => (int)(cislo1 * cislo2),
"/" => (int)(cislo1 / cislo2),
"%" => (int)(cislo1 % cislo2),
_ => throw new Exception("Neznamy operator")
};
27 changes: 13 additions & 14 deletions src/AppsLab-009-Operators/Calculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,86 +10,85 @@ public class Calculator
/// </summary>
public int Add(int a, int b)
{
throw new NotImplementedException();
return a + b;
}

/// <summary>
/// This method subtracts two integers and returns the difference.
/// </summary>
public int Subtract(int a, int b)
{
throw new NotImplementedException();
return a - b;
}

/// <summary>
/// This method multiplies two integers and returns the product.
/// </summary>
public int Multiply(int a, int b)
{
throw new NotImplementedException();
return a * b;
}

/// <summary>
/// This method divides two integers and returns the quotient.
/// </summary>
public double Divide(int a, int b)
{
throw new NotImplementedException();
return (double)a / b;
}

/// <summary>
/// This method divides two integers and returns the remainder.
/// </summary>
public int Remainder(int a, int b)
{
throw new NotImplementedException();
return a % b;
}

/// <summary>
/// This method returns true if the two integers are equal.
/// </summary>
public bool AreEqual(int a, int b)
{
throw new NotImplementedException();
return a == b;
}

/// <summary>
/// This method returns true if the two integers are not equal.
/// </summary>
public bool AreNotEqual(int a, int b)
{
throw new NotImplementedException();
return a != b;
}

/// <summary>
/// This method returns true if the first integer is greater than the second.
/// </summary>
public bool IsGreater(int a, int b)
{
throw new NotImplementedException();
return a > b;
}

/// <summary>
/// This method returns true if the first integer is lesser than the second.
/// </summary>
public bool IsLesser(int a, int b)
public bool IsLesser (int a, int b)
{
throw new NotImplementedException();
return a < b;
}

/// <summary>
/// This method returns true if the first integer is greater than or equal to the second.
/// </summary>
public bool IsGreaterOrEqual(int a, int b)
public bool IsGreaterOrEqual (int a, int b )
{
throw new NotImplementedException();
return a >= b;
}

/// <summary>
/// This method returns true if the first integer is lesser than or equal to the second.
/// </summary>
public bool IsLesserOrEqual(int a, int b)
{
throw new NotImplementedException();
return a <= b;
}
}
Loading