Commit 64509866 authored by Uwe Wienkop's avatar Uwe Wienkop

Klasse Uhrzeit

parent 92ec7a09
......@@ -24,7 +24,7 @@ namespace _09Textdateien
{
Console.WriteLine(zeile);
Console.WriteLine(wort);
//Console.WriteLine(wort);
//Datum d = new Datum(Convert.ToInt32(woerter[0]),
// Convert.ToInt32(woerter[1]),
// Convert.ToInt32(woerter[2]));
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EBFAE108-F2A0-4D00-9562-671D2989FFA3}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>_09Uhrzeit</RootNamespace>
<AssemblyName>09Uhrzeit</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Uhrzeit.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _09Uhrzeit
{
class Program
{
static void Main(string[] args)
{
Zeit z1 = new Zeit(10, 32, 00);
Zeit z2 = new Zeit("10:32:30");
Console.WriteLine(z1);
Console.WriteLine(z2.ToString("h.m:s"));
int std1 = z1.Stunde;
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("09Uhrzeit")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("09Uhrzeit")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ebfae108-f2a0-4d00-9562-671d2989ffa3")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _09Uhrzeit
{
class Zeit
{
private int stunde, minute, sekunde;
public int Stunde
{
get { return stunde; }
}
public override string ToString()
// wird aufgerufen von WriteLine(z1)
{
string erg=ToString("h.m.s"); // $"{stunde}:{minute,2}:{sekunde,2}";
return erg;
}
public string ToString(string format)
{ // wird aufgerufen von WriteLine(z2.ToString("h.m:s"))
string erg = "";
foreach (char c in format)
{
if (c == 'h')
erg += stunde;
else if (c == 'm')
erg += minute;
else if (c == 's')
erg += sekunde;
else
erg += c;
}
return erg;
}
public Zeit(int stunde, int minute, int sekunde=0)
{
this.stunde = stunde;
this.minute = minute;
this.sekunde = sekunde;
validiereUhrzeit();
}
private void validiereUhrzeit()
{
if (stunde < 0 || stunde > 24)
throw new ArgumentOutOfRangeException("Stundenangabe falsch");
if (minute < 0 || minute > 59)
throw new ArgumentOutOfRangeException("Minutenangabe falsch");
if (sekunde < 0 || sekunde > 59)
throw new ArgumentOutOfRangeException("Sekundenangabe falsch");
}
public Zeit(string zeit)
{
string[] werte = zeit.Split(':');
if (werte.Length == 3)
{
stunde = Convert.ToInt32(werte[0]);
minute = Convert.ToInt32(werte[1]);
sekunde = Convert.ToInt32(werte[2]);
}
else
throw new FormatException("Keine gültige Uhrzeit");
}
}
}
......@@ -69,6 +69,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "09Textdateien", "09Textdate
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "09TextdateiSchreiben", "09TextdateiSchreiben\09TextdateiSchreiben.csproj", "{10C582AB-2484-4EC9-BEE9-99FFF732D1E4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "09Uhrzeit", "09Uhrzeit\09Uhrzeit.csproj", "{EBFAE108-F2A0-4D00-9562-671D2989FFA3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -195,6 +197,10 @@ Global
{10C582AB-2484-4EC9-BEE9-99FFF732D1E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10C582AB-2484-4EC9-BEE9-99FFF732D1E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10C582AB-2484-4EC9-BEE9-99FFF732D1E4}.Release|Any CPU.Build.0 = Release|Any CPU
{EBFAE108-F2A0-4D00-9562-671D2989FFA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EBFAE108-F2A0-4D00-9562-671D2989FFA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBFAE108-F2A0-4D00-9562-671D2989FFA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EBFAE108-F2A0-4D00-9562-671D2989FFA3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment