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
31 changes: 31 additions & 0 deletions ForthLesson/EnglishLessons.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2041
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnglishLessons", "EnglishLessons\EnglishLessons.csproj", "{DD163CDC-E328-436C-B273-63767E38334A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnglishLessonsTest", "UserWordTest\EnglishLessonsTest.csproj", "{48A657DC-7910-404A-8232-BB8E243C1C11}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DD163CDC-E328-436C-B273-63767E38334A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD163CDC-E328-436C-B273-63767E38334A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD163CDC-E328-436C-B273-63767E38334A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD163CDC-E328-436C-B273-63767E38334A}.Release|Any CPU.Build.0 = Release|Any CPU
{48A657DC-7910-404A-8232-BB8E243C1C11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48A657DC-7910-404A-8232-BB8E243C1C11}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48A657DC-7910-404A-8232-BB8E243C1C11}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48A657DC-7910-404A-8232-BB8E243C1C11}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2580D6C7-D884-4B79-B5DC-7E633309F635}
EndGlobalSection
EndGlobal
59 changes: 59 additions & 0 deletions ForthLesson/EnglishLessons/EnglishLessons.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>{DD163CDC-E328-436C-B273-63767E38334A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EnglishLessons</RootNamespace>
<AssemblyName>EnglishLessons</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<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="Generator.cs" />
<Compile Include="Memory.cs" />
<Compile Include="RepWord.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Session.cs" />
<Compile Include="User.cs" />
<Compile Include="UserWord.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
43 changes: 43 additions & 0 deletions ForthLesson/EnglishLessons/Generator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EnglishLessons
{
public class Generator
{
public List<RepWord> Start(int count, User user)
{
List<RepWord> toRand = user.ShowInProgress();
Random rnd = new Random();
List<RepWord> toShow = new List<RepWord>();
if (count > toRand.Count) throw new InvalidOperationException();
for (int i = 0; i < count; i++)
{
int ind = rnd.Next(toRand.Count);
toShow.Add(toRand[ind]);
toRand.RemoveAt(ind);
}

toRand = user.ShowInProgress();

for (int i = 0; i < count; i++)
{
if (rnd.Next(2) == 1)
{
string NewRus = "";
Random NewInd = new Random();
do
NewRus = toRand[NewInd.Next(toRand.Count())].Rus;
while (NewRus == toShow[i].Rus);

toShow[i].Rus = NewRus;
}
}

return toRand;
}
}
}
26 changes: 26 additions & 0 deletions ForthLesson/EnglishLessons/Memory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.IO;

namespace EnglishLessons
{
public class Memory
{
public void Save(Session session)
{
string serialized = JsonConvert.SerializeObject(session);
File.Create("FooBar.txt");
File.WriteAllText("FooBar.txt", serialized);
}

public Session Load()
{
string deserialized = File.ReadAllText("FooBar.txt");
return JsonConvert.DeserializeObject<Session>(deserialized);
}
}
}
36 changes: 36 additions & 0 deletions ForthLesson/EnglishLessons/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
// связанные со сборкой.
[assembly: AssemblyTitle("EnglishLessons")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EnglishLessons")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
[assembly: ComVisible(false)]

// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("dd163cdc-e328-436c-b273-63767e38334a")]

// Сведения о версии сборки состоят из следующих четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номер сборки и номер редакции по умолчанию.
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
21 changes: 21 additions & 0 deletions ForthLesson/EnglishLessons/RepWord.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace EnglishLessons
{
public class RepWord
{
public string Rus { get; set; }
public string Eng { get; }

public RepWord(string eng, string rus)
{
Rus = rus;
Eng = eng;
}
}
}
55 changes: 55 additions & 0 deletions ForthLesson/EnglishLessons/Session.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EnglishLessons
{
public class Session
{
private List<RepWord> _allWords { get; set; }
private List<User> _users { get; set; }

private void AddUser(User user)
{
_users.Add(user);
}

private void AddWord(RepWord word)
{
_allWords.Add(word);
}

private bool CheckWord(RepWord word)
{
return _allWords.Contains(word);
}

public void Registration(string name, Guid id)
{
Dictionary<string, UserWord> toReg = new Dictionary<string, UserWord>();
if (_allWords.Count < 10) throw new InvalidOperationException();
for (int i = 0; i < 10; i++)
{
toReg.Add(_allWords[i].Rus, new UserWord(false, 0, _allWords[i].Eng, _allWords[i].Rus));
}
AddUser(new User(name, id, new List<RepWord>(), toReg));
}

public void Start(User user, int wordCount)
{
Generator Gen = new Generator();
List<RepWord> toWork = Gen.Start(wordCount, user);
foreach (RepWord a in toWork)
{
bool UserAnswer = true; //вместо true ответ пользователя
if (CheckWord(a) == UserAnswer)
{
user.MarkAsLearned(a.Eng);
}
}

}
}
}
50 changes: 50 additions & 0 deletions ForthLesson/EnglishLessons/User.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EnglishLessons
{
public class User
{
public string Name { get; set; }
public Guid Id { get; set; }
private List<RepWord> _learned { get; set; }
private Dictionary<string, UserWord> _inProgress { get; set; }

public List<RepWord> ShowLearned()
{
return _learned;
}

public List<RepWord> ShowInProgress()
{
List<RepWord> toShow = new List<RepWord>();
foreach (KeyValuePair<string, UserWord> a in _inProgress)
{
toShow.Add(new RepWord(a.Value.Eng, a.Value.Rus));
}

return toShow;
}

public bool MarkAsLearned(string toMark)
{
if (_inProgress[toMark] == null) return false;

_learned.Add(_inProgress[toMark]);
_inProgress.Remove(toMark);

return true;
}

public User (string name, Guid id, List<RepWord> learned, Dictionary<string, UserWord> inprogress)
{
Name = name;
Id = id;
_learned = learned;
_inProgress = inprogress;
}
}
}
31 changes: 31 additions & 0 deletions ForthLesson/EnglishLessons/UserWord.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EnglishLessons
{
public class UserWord : RepWord
{
public bool Learned { get; private set; }
private int _count { get; set; }

public void Upgrade()
{
_count++;
if (_count >= 3) Learned = true;
}

public bool Check (string toCheck)
{
return (base.Rus == toCheck);
}

public UserWord (bool learned, int count, string eng, string rus) : base(eng, rus)
{
Learned = learned;
_count = count;
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading