Skip to content
Snippets Groups Projects
Commit 984bce72 authored by Vesa Lappalainen's avatar Vesa Lappalainen :bicyclist:
Browse files

live18 alku

parent d2a908f0
No related branches found
No related tags found
No related merge requests found
Showing
with 304 additions and 97 deletions
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/.idea.live18.iml
/contentModel.xml
/projectSettingsUpdater.xml
/modules.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>
\ No newline at end of file
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
/// @author vesal
/// @version 1.11.2016
/// <summary>
/// Esimerkki tyypillisestä filtteristä:
/// Luetaan stdin-syötettä ja tulostetaan sen sisältöä isona
/// </summary>
public class Isoksi
{
/// <summary>
/// Tulostetaan isona syötettä
/// </summary>
public static void Main()
{
while (true)
{
string jono = Console.ReadLine();
if (jono == null) break;
Console.WriteLine(jono.ToUpper());
}
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ExternalConsole>true</ExternalConsole>
</PropertyGroup>
</Project>
kissa istuu
puussa

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Isoksi", "Isoksi\Isoksi.csproj", "{4DB0BEDE-9BA6-4ED7-AD98-022F2E103419}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4DB0BEDE-9BA6-4ED7-AD98-022F2E103419}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DB0BEDE-9BA6-4ED7-AD98-022F2E103419}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DB0BEDE-9BA6-4ED7-AD98-022F2E103419}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DB0BEDE-9BA6-4ED7-AD98-022F2E103419}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/.idea.luento18.iml
/modules.xml
/contentModel.xml
/projectSettingsUpdater.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using Jypeli;
using Jypeli.Assets;
using Jypeli.Controls;
using Jypeli.Effects;
using Jypeli.Widgets;
using System.IO;
using System.Text.RegularExpressions;
using System.Globalization;
namespace Demoajat;
/// <summary>
/// Kuvataan miten demoajat ovat muuttuneet
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C388DEDA-59F8-4AB0-85A1-073C936D3132}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Demoajat</RootNamespace>
<AssemblyName>Demoajat</AssemblyName>
<FileAlignment>512</FileAlignment>
<MonoGamePlatform>Windows</MonoGamePlatform>
<ReferencePath>$(registry:HKEY_LOCAL_MACHINE\Software\MonoJypeli@Install_Dir)\Windows</ReferencePath>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
<TargetFramework>net7.0</TargetFramework>
<PublishReadyToRun>false</PublishReadyToRun>
<TieredCompilation>false</TieredCompilation>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Windows\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Windows\Release\</OutputPath>
<DefineConstants>TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Compile Include="Demoajat.cs" />
<Compile Include="Ohjelma.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Jypeli">
<HintPath>$(registry:HKEY_LOCAL_MACHINE\Software\MonoJypeli@Install_Dir)\WindowsGL\Jypeli.dll</HintPath>
</Reference>
<Reference Include="Jypeli.Physics2d">
<HintPath>$(registry:HKEY_LOCAL_MACHINE\Software\MonoJypeli@Install_Dir)\WindowsGL\Jypeli.Physics2d.dll</HintPath>
</Reference>
<Reference Include="MonoGame.Framework">
<HintPath>$(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Content Include="Icon.ico" />
</ItemGroup>
<ItemGroup>
<MonoGameContentReference Include="Content\Content.mgcb" />
<PackageReference Include="Jypeli.NET" Version="11.3.3" />
<PackageReference Include="Jypeli.FarseerPhysics.NET" Version="2.*" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Jypeli\MonoJypeli.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
</Project>
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
#endregion
using System;
namespace Program
namespace Demoajat;
/// <summary>
/// The main class.
/// </summary>
public static class Program
{
#if WINDOWS || LINUX
/// <summary>
/// The main class.
/// The main entry point for the application.
/// </summary>
public static class Program
[STAThread]
static void Main()
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
using (var game = new Demoajat())
{
game.args = args;
game.Run();
}
}
using (var game = new Demoajat())
game.Run();
}
#endif
}
}
\ No newline at end of file
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
/// @author Omanimi
/// @version Päivämäärä
/// <summary>
/// <pre>
/// Aluksi kysyy
/// Anna tulos>?????
/// APINA
/// KISSA
/// KETTU
/// KOIRA
/// ...
/// Anna arvaamasi kirjain>A
/// Anna tulos >A???A
/// APINA
/// Anna arvaamasi kirjain>I
/// Anna tulos >A?I?A
///
/// </pre>
/// </summary>
public class Hirsiauta
{
/// <summary>
///
/// </summary>
public static void Main(string[] args)
{
string nimi = "sanat.txt";
if (args.Length > 0) nimi = args[0];
string[] sanat = File.ReadAllLines(nimi);
StringBuilder kaytetyt = new StringBuilder();
string piste = ".";
string tulos = "";
while (true)
{
Console.Write($"Anna tulos ({tulos})>");
string t = Console.ReadLine();
if (t == null || t == "!") break;
if (t != "") tulos = t;
Jakauma jakauma = new Jakauma(kaytetyt.ToString());
string maski = tulos.Replace("?", piste);
Regex regex = new Regex("^" + maski + "$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
foreach (string rivi in sanat) // tutkitaan mitkä rivit täsmäävät
{
Match match = regex.Match(rivi);
if (match.Success)
{
Console.WriteLine(rivi);
jakauma.Add(rivi);
}
}
Console.WriteLine(jakauma.ToString(5));
Console.Write("Anna arvaamasi kirjain >");
string kirjain = Console.ReadLine() ?? "";
kirjain = kirjain.ToUpper();
kaytetyt.Append(kirjain);
piste = "[^" + kaytetyt + "]"; // tulee esim [^AUO]
}
}
}
/// <summary>
/// Jakaumalaskuri joka laskee kuinka paljon mitäkin kirjainta esiintyy.
/// Alustuksessa voidaan antaa mitä kirjaimia ei oteta huomioon.
/// </summary>
public class Jakauma
{
// TODO: tähän sopiva attribuutti tai attribuutit jotta saadaan laskettua
// ReSharper disable once NotAccessedField.Local
private readonly string eiLisata;
/// <summary>
/// Alustaan jakaumalaskuri niin, että laskuihin ei oteta annettua kirjainjoukkoa
/// </summary>
/// <param name="eiLisata">mitä kirjaimia ei lasketa mukaan</param>
public Jakauma(string eiLisata = "")
{
this.eiLisata = eiLisata;
}
/// <summary>
/// Lisätään rakenteesen yksi kirjain jollei se ole kielletyissä
/// </summary>
/// <param name="c">lisättävä kirjain</param>
/// <example>
/// <pre name="test">
/// Jakauma jakauma = new Jakauma();
/// jakauma.Add('a');
/// jakauma.Add('i');
/// jakauma.Add('a');
/// jakauma.ToString(4) === "a:2 i:1";
/// </pre>
/// </example>
public void Add(char c)
{
// TODO: tee kuten kommenteissa on ja niin että testit menevät läpi
}
/// <summary>
/// Lisätään kaikki jonon kirjaimet jotka eivät ole kielletyissä
/// </summary>
/// <param name="rivi">jono jonka kirjaimet lisätään jakaumaan</param>
/// <example>
/// <pre name="test">
/// Jakauma jakauma = new Jakauma("ei ");
/// jakauma.Add("kissa ei istu puussa");
/// jakauma.ToString(10) === "s:5 u:3 a:2 k:1 t:1 p:1";
/// </pre>
/// </example>
public void Add(string rivi)
{
// TODO: lisää kirjaimet
}
/// <summary>
/// Palautetaan jakauma merkkijonona jossa on n ensimmäistä yleisintä kirjainta
/// </summary>
/// <param name="n">kuinka monta kirjainta laitetaan jonoon</param>
/// <returns></returns>
/// <example>
/// <pre name="test">
/// Jakauma jakauma = new Jakauma(" ");
/// jakauma.Add("kissa ei istu puussa");
/// jakauma.ToString(2) === "s:5 i:3";
/// </pre>
/// </example>
public string ToString(int n)
{
return "S:5 I:3";
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ExternalConsole>true</ExternalConsole>
</PropertyGroup>
<ItemGroup>
<None Update="sanat.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
......@@ -14,6 +14,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Isoksi", "Isoksi\Isoksi.csp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demoajat", "Demoajat\Demoajat.csproj", "{C388DEDA-59F8-4AB0-85A1-073C936D3132}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hirsiauta", "Hirsiauta\Hirsiauta.csproj", "{A9F7D1AC-A24E-4BC5-A0A0-4CAF2D562AA4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
......@@ -44,6 +46,10 @@ Global
{C388DEDA-59F8-4AB0-85A1-073C936D3132}.Debug|x86.Build.0 = Debug|x86
{C388DEDA-59F8-4AB0-85A1-073C936D3132}.Release|x86.ActiveCfg = Release|x86
{C388DEDA-59F8-4AB0-85A1-073C936D3132}.Release|x86.Build.0 = Release|x86
{A9F7D1AC-A24E-4BC5-A0A0-4CAF2D562AA4}.Debug|x86.ActiveCfg = Debug|Any CPU
{A9F7D1AC-A24E-4BC5-A0A0-4CAF2D562AA4}.Debug|x86.Build.0 = Debug|Any CPU
{A9F7D1AC-A24E-4BC5-A0A0-4CAF2D562AA4}.Release|x86.ActiveCfg = Release|Any CPU
{A9F7D1AC-A24E-4BC5-A0A0-4CAF2D562AA4}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment