Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!";
}
}
8 changes: 7 additions & 1 deletion src/AppsLab-002-ConsoleWriteLine/Program.cs
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
Console.WriteLine("Hello, World!");
int age = 10;
string name = "george";

Console.WriteLine(age);
Console.WriteLine(name);

Console.WriteLine($"My name is {name} and I am {age} years old.");
18 changes: 16 additions & 2 deletions src/AppsLab-005-DataTypes/Program.cs
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
int mojeCislo = 1234;
string mojeSlovo = "Ahoj, svet!";
bool mojaBoolHodnota = true;
DateTime dnesnyDatum = DateTime.Now;
float myFloat = 5.75f;
int sucet = mojeCislo + 65;
var myVar = "Toto je var string";

Console.WriteLine(mojeCislo.ToString("000000"));
Console.WriteLine(mojeSlovo);
Console.WriteLine($"Súčet je: {sucet}");
Console.WriteLine($"dnes je robotkac{dnesnyDatum.ToString("yyyy-MM-dd")}");
Console.WriteLine($"mojaBoolHodnota je: {mojaBoolHodnota}");
Console.WriteLine(myVar);
Console.WriteLine(myFloat);
Console.WriteLine("Maximálny počet študentov v triede je: " + 30);
10 changes: 8 additions & 2 deletions src/AppsLab-006-Constants/Program.cs
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
const int MaxPoints = 200;
const int MinAgeForDriversLicense = 16;
const string WelcomeMessage = "Welcome to the Gulag!";

Console.WriteLine(MaxPoints);
Console.WriteLine(MinAgeForDriversLicense);
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);
}
}
9 changes: 6 additions & 3 deletions src/AppsLab-008-ConsoleReadLine/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
Console.WriteLine("Ako sa voláš?");
string? meno = Console.ReadLine();
Console.WriteLine("Ahoj, " + meno);
Console.WriteLine(" Ahoj, " + meno + " koľko máš rokov? ");

Console.WriteLine("Koľko máš rokov?");
string vstup = Console.ReadLine() ?? "0";
int vek = int.Parse(vstup);
Console.WriteLine("Máš " + vek + " rokov.");
Console.WriteLine("Aha,máš teda " + vek + " rokov.");

Console.WriteLine("Aké je tvoje obľúbené jedlo? ");
string jedlo = Console.ReadLine() ?? "0";
Console.WriteLine(jedlo + " to znie skvele. ");
6 changes: 3 additions & 3 deletions tests/AppsLab-007-Casting.Tests/ConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ public void IntToDouble_Given7_ShouldReturn7Point0()
[Test]
public void DoubleToInt_Given7Point8_ShouldReturn7()
{
var result = converter.DoubleToInt(7.8);
var result = converter.DoubleToInt(7.4);
Assert.That(result, Is.EqualTo(7), "DoubleToInt(7.8) should return 7");
}

[Test]
public void StringToDouble_Given7Point8AsString_ShouldReturn7Point8()
{
var result = converter.StringToDouble("7.8");
var result = converter.StringToDouble("7,8");
Assert.That(result, Is.EqualTo(7.8), "StringToDouble(\"7.8\") should return 7.8");
}

[Test]
public void DoubleToString_Given7Point8_ShouldReturn7Point8AsString()
{
var result = converter.DoubleToString(7.8);
Assert.That(result, Is.EqualTo("7.8"), "DoubleToString(7.8) should return \"7.8\"");
Assert.That(result, Is.EqualTo("7,8"), "DoubleToString(7.8) should return \"7.8\"");
}

[Test]
Expand Down