Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions core/encoding/cyrillic-to-latin/cs/Common/Common.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
namespace CyrillicToLatin.Common
{
public static class Common
{
public const string NoSourceOrDestinationFile = "There must be a source and a destination file.";

public const string FileDoesntExist = "The source file does not exist.";

public const string WrongDirectory = "Invalid directory: {0}";

public const string WrongIO = "I/O exception: {0}";
}
}

13 changes: 8 additions & 5 deletions core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using System.IO;
using System.Security.AccessControl;
using System.Text;
using CyrillicToLatin.Common;


class ConsoleModule
{
Expand All @@ -9,9 +12,9 @@ static void Main()
string[] args = Environment.GetCommandLineArgs();

// Get command line arguments.
if (args.Length != 3 || String.IsNullOrWhiteSpace(args[1]) || String.IsNullOrWhiteSpace(args[2]))
if (args.Length != 3 || string.IsNullOrWhiteSpace(args[1]) || string.IsNullOrWhiteSpace(args[2]))
{
Console.WriteLine("There must be a source and a destination file.");
Console.WriteLine(Common.NoSourceOrDestinationFile);
ShowSyntax();
return;
}
Expand All @@ -21,7 +24,7 @@ static void Main()

if (!File.Exists(source))
{
Console.WriteLine("The source file does not exist.");
Console.WriteLine(Common.NoSourceOrDestinationFile);
return;
}

Expand Down Expand Up @@ -74,12 +77,12 @@ static void Main()
}
catch (DirectoryNotFoundException e)
{
Console.WriteLine($"Invalid directory: {e.Message}");
Console.WriteLine(Common.WrongDirectory);
return;
}
catch (IOException e)
{
Console.WriteLine($"I/O exception: {e.Message}");
Console.WriteLine(Common.WrongIO);
return;
}
}
Expand Down
6 changes: 6 additions & 0 deletions core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<None Remove="Common\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Common\" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions core/encoding/cyrillic-to-latin/cs/CyrillicToLatinFallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

class CyrillicToLatinFallback : EncoderFallback
{
private Dictionary<Char, String> table;
private Dictionary<char, string> table;

public CyrillicToLatinFallback()
{
table = new Dictionary<Char, String>();
table = new Dictionary<char, string>();
// Define mappings.
// Uppercase modern Cyrillic characters.
table.Add('\u0410', "A");
Expand Down Expand Up @@ -92,12 +92,12 @@ public override int MaxCharCount

public class CyrillicToLatinFallbackBuffer : EncoderFallbackBuffer
{
private Dictionary<Char, String> table;
private Dictionary<char, string> table;
private int bufferIndex;
private string buffer;
private int leftToReturn;

internal CyrillicToLatinFallbackBuffer(Dictionary<Char, String> table)
internal CyrillicToLatinFallbackBuffer(Dictionary<char, string> table)
{
this.table = table;
this.bufferIndex = -1;
Expand Down Expand Up @@ -153,4 +153,4 @@ public override int Remaining
{
get { return leftToReturn; }
}
}
}
11 changes: 7 additions & 4 deletions csharp/classes-quickstart/BankAccount.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System;
using System.Collections.Generic;
using classes.Contracts;

namespace classes
{
public class BankAccount
public class BankAccount : IBank
{
public string Number { get; }
public string Number { get; set; }
public string Owner { get; set; }
#region BalanceComputation
public decimal Balance
Expand All @@ -21,6 +22,7 @@ public decimal Balance
return balance;
}
}

#endregion

private static int accountNumberSeed = 1234567890;
Expand All @@ -36,7 +38,8 @@ public BankAccount(string name, decimal initialBalance)
#endregion

#region TransactionDeclaration
private List<Transaction> allTransactions = new List<Transaction>();

private List<ITransaction> allTransactions = new List<ITransaction>();
#endregion

#region DepositAndWithdrawal
Expand Down Expand Up @@ -82,4 +85,4 @@ public string GetAccountHistory()
}
#endregion
}
}
}
14 changes: 14 additions & 0 deletions csharp/classes-quickstart/Contracts/IBank.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;

namespace classes.Contracts
{
public interface IBank
{
public string Number { get; }

public string Owner { get; }

public decimal Balance { get; }
}
}
12 changes: 12 additions & 0 deletions csharp/classes-quickstart/Contracts/ITransaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
namespace classes.Contracts
{
public interface ITransaction
{
public decimal Amount { get; }

public DateTime Date { get; }

public string Notes { get; }
}
}
6 changes: 6 additions & 0 deletions csharp/classes-quickstart/classes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<None Remove="Contracts\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Contracts\" />
</ItemGroup>
</Project>
9 changes: 5 additions & 4 deletions csharp/classes-quickstart/transaction.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System;
using classes.Contracts;

namespace classes
{
public class Transaction
public class Transaction : ITransaction
{
public decimal Amount { get; }
public decimal Amount { get; set; }
public DateTime Date { get; }
public string Notes { get; }
public string Notes { get; set; }

public Transaction(decimal amount, DateTime date, string note)
{
Expand All @@ -15,4 +16,4 @@ public Transaction(decimal amount, DateTime date, string note)
this.Notes = note;
}
}
}
}
Loading