-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
// Ukoncovaci Prikazy - RETURN, BREAK, CONTINUE | ||
Console.WriteLine("Začátek programu."); | ||
while (true) | ||
{ | ||
Console.WriteLine("Začátek nekonečného cyklu, první část... Vykoná se vždy."); | ||
|
||
Console.WriteLine("Chceš ukončit program? A/N"); | ||
string vstupUzivatele = Console.ReadLine(); | ||
if (vstupUzivatele == "A") | ||
{ | ||
Console.WriteLine("Končím program."); | ||
return; // ukoncime program | ||
} | ||
|
||
Console.WriteLine("Chceš vyskočit z aktuálního cyklu? A/N"); | ||
vstupUzivatele = Console.ReadLine(); | ||
if (vstupUzivatele == "A") | ||
{ | ||
Console.WriteLine("Vyskakuju z aktuálního cyklu."); | ||
break; // vyskocime z aktualniho cyklu | ||
} | ||
|
||
Console.WriteLine("Chceš přeskočit následující část program a vrátit se na začátek cyklu? A/N"); | ||
vstupUzivatele = Console.ReadLine(); | ||
if (vstupUzivatele == "A") | ||
{ | ||
Console.WriteLine("Vracím se na začátek cyklu."); | ||
continue; // preskoci zbytek cyklu a vraci se na jeho zacatek | ||
} | ||
|
||
Console.WriteLine("Toto je druhá část programu..."); | ||
} | ||
|
||
Console.WriteLine("Konec programu."); | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Lekce05.Vyklad.MetodyPokrocile/Lekce05.Vyklad.MetodyPokrocile.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
//string textOdUzivatele = Console.ReadLine(); // volani metody s vystepem bez vstupnich parametru | ||
|
||
JsemHladovyPoXHodinach(2); // vystup metody zahodim | ||
bool jsemHladovy = JsemHladovyPoXHodinach(2); // vystup metody ulozim do promenne | ||
Console.WriteLine($"Jsem hladovy: {jsemHladovy}"); | ||
jsemHladovy = JsemHladovyPoXHodinach(7); | ||
Console.WriteLine($"Jsem hladovy: {jsemHladovy}"); | ||
|
||
int vypocitanyVek = VypocitejMujVek(1990); | ||
Console.WriteLine($"Tvuj vypocitany vek je {vypocitanyVek}"); | ||
|
||
vypocitanyVek = UzivatelZadaSvujRokNarozeniAVypocitaSeJehoVek(); | ||
} | ||
|
||
// Metoda se vstupem a vystupem | ||
public static bool JsemHladovyPoXHodinach(int pocetHodin) | ||
{ | ||
if (pocetHodin >= 6) | ||
{ | ||
return true; | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
public static int VypocitejMujVek(int rokNarozeni) | ||
{ | ||
int vek = 2025 - rokNarozeni; | ||
return vek; | ||
// return 2025 - rokNarozeni; | ||
} | ||
|
||
public static int UzivatelZadaSvujRokNarozeniAVypocitaSeJehoVek() | ||
{ | ||
Console.WriteLine("Zadej svuj rok narozeni:"); | ||
string textOdUzivatele = Console.ReadLine(); | ||
int rokNarozeni = int.Parse(textOdUzivatele); | ||
int vypocitanyVek = 2025 - rokNarozeni; | ||
|
||
Console.WriteLine($"Tvuj vypocitany vek je {vypocitanyVek}"); | ||
return vypocitanyVek; | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/Lekce05.Vyklad.MetodyZaklad/Lekce05.Vyklad.MetodyZaklad.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
Zastekej(); | ||
Zastekej(); | ||
Zastekej(); | ||
|
||
Zastekej(5); | ||
|
||
int celeCislo = 5; | ||
string text = "LibovolnyText"; | ||
|
||
Console.WriteLine(celeCislo); | ||
Console.WriteLine(text); | ||
} | ||
|
||
//Metoda bez parametru a bez navratove hodnoty | ||
public static void Zastekej() | ||
{ | ||
Console.WriteLine("Haf!"); | ||
} | ||
|
||
public static void Zastekej(int kolikrat) | ||
{ | ||
Console.WriteLine($"Zastekej {kolikrat}x!"); | ||
for (int i = 0; i < kolikrat; i++) | ||
{ | ||
Zastekej(); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Lekce05.Vyklad.UkoncovaciPrikazy/Lekce05.Vyklad.UkoncovaciPrikazy.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Ukoncovaci Prikazy - RETURN, BREAK, CONTINUE | ||
Console.WriteLine("Začátek programu."); | ||
while (true) | ||
{ | ||
Console.WriteLine("Začátek nekonečného cyklu, první část... Vykoná se vždy."); | ||
|
||
Console.WriteLine("Chceš ukončit program? A/N"); | ||
string vstupUzivatele = Console.ReadLine(); | ||
if (vstupUzivatele == "A") | ||
{ | ||
Console.WriteLine("Končím program."); | ||
return; // ukoncime program | ||
} | ||
|
||
Console.WriteLine("Chceš vyskočit z aktuálního cyklu? A/N"); | ||
vstupUzivatele = Console.ReadLine(); | ||
if (vstupUzivatele == "A") | ||
{ | ||
Console.WriteLine("Vyskakuju z aktuálního cyklu."); | ||
break; // vyskocime z aktualniho cyklu | ||
} | ||
|
||
Console.WriteLine("Chceš přeskočit následující část program a vrátit se na začátek cyklu? A/N"); | ||
vstupUzivatele = Console.ReadLine(); | ||
if (vstupUzivatele == "A") | ||
{ | ||
Console.WriteLine("Vracím se na začátek cyklu."); | ||
continue; // preskoci zbytek cyklu a vraci se na jeho zacatek | ||
} | ||
|
||
Console.WriteLine("Toto je druhá část programu..."); | ||
} | ||
|
||
Console.WriteLine("Konec programu."); |