This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDocuments.cs
49 lines (39 loc) · 1.42 KB
/
Documents.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
namespace ver1
{
public interface IDocument
{
enum FormatType {TXT, PDF, JPG}
/// <summary>
/// Zwraca typ formatu dokumentu
/// </summary>
FormatType GetFormatType();
/// <summary>
/// Zwraca nazwę pliku dokumentu - nie może być `null` ani pusty `string`
/// </summary>
string GetFileName();
}
public abstract class AbstractDocument : IDocument
{
private string fileName;
public AbstractDocument(string fileName) => this.fileName = fileName;
public string GetFileName() => fileName;
public void ChangeFileName(string newFileName) => fileName = newFileName;
public abstract IDocument.FormatType GetFormatType();
}
public class PDFDocument : AbstractDocument
{
public PDFDocument(string filename) : base(filename) { }
public override IDocument.FormatType GetFormatType() => IDocument.FormatType.PDF;
}
public class ImageDocument : AbstractDocument
{
public ImageDocument(string filename) : base(filename) { }
public override IDocument.FormatType GetFormatType() => IDocument.FormatType.JPG;
}
public class TextDocument : AbstractDocument
{
public TextDocument(string filename) : base(filename) { }
public override IDocument.FormatType GetFormatType() => IDocument.FormatType.TXT;
}
}