add Programmyday form github
This commit is contained in:
20
E-Book/Audio.cs
Normal file
20
E-Book/Audio.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E_Book
|
||||
{
|
||||
internal class Audio : MediaAssets
|
||||
{
|
||||
private decimal ptis;
|
||||
private decimal audioPages;
|
||||
public Audio(decimal ptis)
|
||||
{
|
||||
this.ptis = ptis;
|
||||
this.audioPages = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
E-Book/E-Book.csproj
Normal file
11
E-Book/E-Book.csproj
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>E_Book</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
38
E-Book/EBook.cs
Normal file
38
E-Book/EBook.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E_Book
|
||||
{
|
||||
internal class EBook
|
||||
{
|
||||
private string? author;
|
||||
private string? publishingYear;
|
||||
private MediaAssets[] media;
|
||||
private decimal totalPageCount;
|
||||
|
||||
public EBook(int number)
|
||||
{
|
||||
media = new MediaAssets[number];
|
||||
}
|
||||
public bool AddMediaAsset(MediaAssets pageCount)
|
||||
{
|
||||
for (int i = 0; i < media.Length; i++)
|
||||
{
|
||||
if (media[i] is null)
|
||||
{
|
||||
media[i] = pageCount;
|
||||
totalPageCount += media[i].GetPageCount();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void PrintInof()
|
||||
{
|
||||
Console.WriteLine($"Das Buch hat {totalPageCount} Seiten,");
|
||||
}
|
||||
}
|
||||
}
|
||||
18
E-Book/MediaAssets.cs
Normal file
18
E-Book/MediaAssets.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E_Book
|
||||
{
|
||||
internal class MediaAssets
|
||||
{
|
||||
protected decimal pageCount;
|
||||
|
||||
public decimal GetPageCount()
|
||||
{
|
||||
return pageCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
E-Book/MediaMath.cs
Normal file
16
E-Book/MediaMath.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E_Book
|
||||
{
|
||||
internal static class MediaMath
|
||||
{
|
||||
public static decimal DimensionsMath(decimal pixelHeight, decimal pixelWidth)
|
||||
{
|
||||
return pixelHeight * (960 / pixelWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
E-Book/Picture.cs
Normal file
30
E-Book/Picture.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E_Book
|
||||
{
|
||||
internal class Picture : MediaAssets
|
||||
{
|
||||
private decimal pixelWidth;
|
||||
private decimal pixelHeight;
|
||||
private decimal aspectraiton;
|
||||
public Picture(decimal pixelHeight, decimal pixelWidth)
|
||||
{
|
||||
this.pixelHeight = pixelHeight;
|
||||
this.pixelWidth = pixelWidth;
|
||||
this.aspectraiton = MediaMath.DimensionsMath(this.pixelHeight,this.pixelWidth);
|
||||
if (this.aspectraiton > 600)
|
||||
{
|
||||
this.pageCount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pageCount = 1 / 2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
19
E-Book/Program.cs
Normal file
19
E-Book/Program.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace E_Book
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
MediaAssets text = new Texte(20);
|
||||
MediaAssets video = new Video(20,49);
|
||||
MediaAssets picture = new Picture(100, 200);
|
||||
MediaAssets audio = new Audio(0);
|
||||
EBook eBook = new EBook(50);
|
||||
eBook.AddMediaAsset(text);
|
||||
eBook.AddMediaAsset(video);
|
||||
eBook.AddMediaAsset(picture);
|
||||
eBook.AddMediaAsset(audio);
|
||||
eBook.PrintInof();
|
||||
}
|
||||
}
|
||||
}
|
||||
18
E-Book/Texte.cs
Normal file
18
E-Book/Texte.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E_Book
|
||||
{
|
||||
internal class Texte : MediaAssets
|
||||
{
|
||||
private decimal charCount;
|
||||
public Texte(decimal charCount)
|
||||
{
|
||||
this.charCount = charCount;
|
||||
this.pageCount = Math.Ceiling(charCount / 2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
E-Book/Video.cs
Normal file
30
E-Book/Video.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E_Book
|
||||
{
|
||||
internal class Video : MediaAssets
|
||||
{
|
||||
private decimal pixelWidth;
|
||||
private decimal pixelHeight;
|
||||
private decimal aspectraiton;
|
||||
public Video(decimal pixelHeight, decimal pixelWidth)
|
||||
{
|
||||
this.pixelHeight = pixelHeight;
|
||||
this.pixelWidth = pixelWidth;
|
||||
this.aspectraiton = MediaMath.DimensionsMath(this.pixelHeight, this.pixelWidth);
|
||||
if (this.aspectraiton > 600)
|
||||
{
|
||||
this.pageCount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pageCount = 1 / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user