add Programmyday form github
This commit is contained in:
29
TvSteuerung/Program.cs
Normal file
29
TvSteuerung/Program.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
namespace TvSteuerung
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
TV tvstatus = new TV();
|
||||
Console.Write("Tv status: ");
|
||||
tvstatus.SetSwitchedOn(Console.ReadLine());
|
||||
tvstatus.GetInfostatus();
|
||||
|
||||
Console.Write("Programm auswählen: ");
|
||||
tvstatus.SetChannel(Console.ReadLine());
|
||||
tvstatus.GetInfoChannel();
|
||||
|
||||
Console.Write("Lautstärke: ");
|
||||
tvstatus.SetVolume(Convert.ToInt16(Console.ReadLine()));
|
||||
tvstatus.GetInfoVolum();
|
||||
|
||||
Console.Write("Lauter: ");
|
||||
tvstatus.SetRaiseVolume(Console.ReadLine());
|
||||
tvstatus.GetInfoVolum();
|
||||
|
||||
Console.Write("leiser: ");
|
||||
tvstatus.SetLowerVolume(Console.ReadLine());
|
||||
tvstatus.GetInfoVolum();
|
||||
}
|
||||
}
|
||||
}
|
||||
83
TvSteuerung/TV.cs
Normal file
83
TvSteuerung/TV.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TvSteuerung
|
||||
{
|
||||
internal class TV
|
||||
{
|
||||
private bool switchedOn;
|
||||
private int volume;
|
||||
private string? channel;
|
||||
|
||||
//*set-volumen**
|
||||
public void SetVolume(int volumen)
|
||||
{ this.volume = volumen; }
|
||||
public string GetVolume()
|
||||
{
|
||||
if (volume == 0) { return "ton aus"; }
|
||||
else if (volume > 1 && volume <= 9) { return "1%"; }
|
||||
else if (volume > 9 && volume <= 19) { return "10%"; }
|
||||
else if (volume > 19 && volume <= 29) { return "20%"; }
|
||||
else if (volume > 29 && volume <= 39) { return "30%"; }
|
||||
else if (volume > 39 && volume <= 49) { return "40%"; }
|
||||
else if (volume > 49 && volume <= 59) { return "50%"; }
|
||||
else if (volume > 59 && volume <= 69) { return "60%"; }
|
||||
else if (volume > 69 && volume <= 79) { return "70%"; }
|
||||
else if (volume > 79 && volume <= 89) { return "80%"; }
|
||||
else if (volume > 89 && volume <= 99) { return "90%"; }
|
||||
else return "100%";
|
||||
}
|
||||
//**volum-raise/-lower**
|
||||
public void SetRaiseVolume(string volumen)
|
||||
{
|
||||
if (volumen == "+" && volume <=90 ) { volume += 10; }
|
||||
}
|
||||
public void SetLowerVolume(string volumen)
|
||||
{
|
||||
if (volumen == "-" ) { volume -= 10; }
|
||||
}
|
||||
//**power-on/-off**
|
||||
public void SetSwitchedOn(string switchedOn)
|
||||
{
|
||||
if (switchedOn == "an") { this.switchedOn = true; }
|
||||
else this.switchedOn = false;
|
||||
}
|
||||
public string GetSwitchedOn()
|
||||
{
|
||||
if (switchedOn == true) { return "an"; }
|
||||
else return "aus";
|
||||
}
|
||||
//**channel-surfing**
|
||||
public void SetChannel(string channel)
|
||||
{ this.channel = channel; }
|
||||
public string GetChannel()
|
||||
{
|
||||
if (channel == "1") { return "Das Erste"; }
|
||||
else if (channel == "2") { return "Das Zweite"; }
|
||||
else if (channel == "3") { return "Das Dritte"; }
|
||||
else if (channel == "4") { return "rtl"; }
|
||||
else if (channel == "5") { return "sat1"; }
|
||||
else if (channel == "6") { return "rtl2"; }
|
||||
else if (channel == "7") { return "ProSieben"; }
|
||||
else return "tv wird ausgeschaltet läuft sowieso nichts gutes.";
|
||||
}
|
||||
//**info-printing**
|
||||
public void GetInfostatus()
|
||||
{
|
||||
Console.WriteLine($"Fernseher: {GetSwitchedOn()}");
|
||||
}
|
||||
public void GetInfoChannel()
|
||||
{
|
||||
Console.WriteLine($"Channel: {GetChannel()}");
|
||||
}
|
||||
public void GetInfoVolum()
|
||||
{
|
||||
Console.WriteLine($"Lautstärke {GetVolume()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
10
TvSteuerung/TvSteuerung.csproj
Normal file
10
TvSteuerung/TvSteuerung.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user