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

live08

parent f50b0444
No related branches found
No related tags found
No related merge requests found
Showing
with 434 additions and 0 deletions
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/// @author Omanimi
/// @version Päivämäärä
/// <summary>
///
/// </summary>
public class Lukuja
{
/// <summary>
///
/// </summary>
public static void Main()
{
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ExternalConsole>true</ExternalConsole>
</PropertyGroup>
</Project>

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32819.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "live08", "live08\live08.csproj", "{87F8B6B7-F798-438D-8AF0-091A74802A34}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{87F8B6B7-F798-438D-8AF0-091A74802A34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87F8B6B7-F798-438D-8AF0-091A74802A34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87F8B6B7-F798-438D-8AF0-091A74802A34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87F8B6B7-F798-438D-8AF0-091A74802A34}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {96C32762-4373-40E3-8DA7-0558B0048AD7}
EndGlobalSection
EndGlobal
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/// @author Omanimi
/// @version Päivämäärä
/// <summary>
///
/// </summary>
public class live08
{
/// <summary>
///
/// </summary>
public static void Main()
{
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ExternalConsole>true</ExternalConsole>
</PropertyGroup>
</Project>
public class HelloWorld
{
public static void Main()
{
int a = 5, b = 3;
int c = Vahenna(a, b+4);
System.Console.WriteLine(c);
}
/// <summary>
/// skldjlka
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
/// <example>
/// <pre name="test">
/// Vahenna(0,0) === 0;
/// Vahenna(5,3) === 2;
/// Vahenna(5,8) === -3;
/// </pre>
/// </example>
public static int Vahenna(int a, int b)
{
int tulos;
tulos = a - b;
return tulos;
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ExternalConsole>true</ExternalConsole>
</PropertyGroup>
</Project>
luennot/live07/KolmionMetsastys/Content/leijona.png

2.03 KiB

using System;
using System.Collections.Generic;
using Jypeli;
using Jypeli.Assets;
using Jypeli.Controls;
using Jypeli.Effects;
using Jypeli.Widgets;
namespace KolmionMetsastys;
public class KolmionMetsastys : PhysicsGame
{
public override void Begin()
{
Level.Background.Color = Color.Black;
Camera.ZoomToLevel();
for (int i = 0; i < 100; i++)
LuoSatunnainenKolmio(this, Level.Left, Level.Bottom, Level.Right, 0);
PhysicsObject pelaaja = LuoSatunnainenKolmio(this, Level.Left, 0, Level.Right, Level.Top);
pelaaja.Image = LoadImage("leijona");
PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");
Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
}
public static PhysicsObject LuoSatunnainenKolmio(PhysicsGame peli, double minx, double miny,
double maxx, double maxy)
{
double leveys = RandomGen.NextDouble(10, 100);
double korkeus = RandomGen.NextDouble(10, 100);
PhysicsObject kolmio = new PhysicsObject(leveys, korkeus, Shape.Triangle);
kolmio.Position = RandomGen.NextVector(minx, miny, maxx, maxy);
kolmio.Angle = RandomGen.NextAngle();
kolmio.Color = RandomGen.NextColor();
peli.Add(kolmio);
return kolmio;
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<PublishReadyToRun>false</PublishReadyToRun>
<TieredCompilation>false</TieredCompilation>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Jypeli.NET" Version="11.*" />
<PackageReference Include="Jypeli.FarseerPhysics.NET" Version="2.*" />
</ItemGroup>
<ItemGroup>
<None Update="Content\leijona.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
#endregion
namespace KolmionMetsastys
{
/// <summary>
/// The main class.
/// </summary>
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
using var game = new KolmionMetsastys();
game.Run();
}
}
}

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32819.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "HelloWorld\HelloWorld.csproj", "{475209CC-23BC-4C79-B947-555473334D7B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KolmionMetsastys", "KolmionMetsastys\KolmionMetsastys.csproj", "{9E8AB663-6004-4356-9696-1D2490FB3625}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{475209CC-23BC-4C79-B947-555473334D7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{475209CC-23BC-4C79-B947-555473334D7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{475209CC-23BC-4C79-B947-555473334D7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{475209CC-23BC-4C79-B947-555473334D7B}.Release|Any CPU.Build.0 = Release|Any CPU
{9E8AB663-6004-4356-9696-1D2490FB3625}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E8AB663-6004-4356-9696-1D2490FB3625}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E8AB663-6004-4356-9696-1D2490FB3625}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E8AB663-6004-4356-9696-1D2490FB3625}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2A1BC2DE-8BCB-4BE2-95C1-56B7CF5346E8}
EndGlobalSection
EndGlobal
using System;
/// @author Vesa Lappalainen
/// @version 27.09.2011
///
/// <summary>
/// Tutkitaan funktioita jotka palauttavat toisen luvuista
/// </summary>
public class Lukuja
{
/// <summary>
/// Tutkitaan kumpiko luvuista on toistaan suurempi
/// </summary>
public static void Main()
{
int a = 5;
int b = 4;
//double d = 1.234567;
//Console.WriteLine("a={0:000} ja d={1:0.00}", a, d); // a=005 ja d=1.23
//Console.WriteLine("a={0,5:000} ja d={1,10:0.00}", a, d); // a= 005 ja d= 1.23
//Console.WriteLine("a={0,-5:000} ja d={1,10:0.00}", a, d); // a=005 ja d= 1.23
// a = Kysy("Anna 1. luku", a);
// b = Kysy("Anna 2. luku", b);
int iso = Suurempi(a, b);
int pieni = Pienempi(a, b);
Console.WriteLine("Suurempi oli: " + iso);
Console.WriteLine("Pienempi oli: " + pieni);
}
/// <summary>
/// Palauttaa sureemman arvon kahdesta luvutsa
/// </summary>
/// <param name="a">eka </param>
/// <param name="b">toka</param>
/// <returns>suurempi kahdesta</returns>
/// <example>
/// <pre name="test">
/// Suurempi(3, 4) === 4;
/// Suurempi(7, 5) === 7;
/// Suurempi(6, 6) === 6;
/// </pre>
/// </example>
public static int Suurempi(int a, int b)
{
int voittaja = a;
if (b > voittaja) voittaja = b;
return voittaja;
}
/// <summary>
/// Palauttaa sureemman arvon kahdesta luvutsa
/// </summary>
/// <param name="a">eka </param>
/// <param name="b">toka</param>
/// <returns>suurempi kahdesta</returns>
/// <example>
/// <pre name="test">
/// Pienempi(3, 4) === 3;
/// Pienempi(7, 5) === 5;
/// Pienempi(6, 6) === 6;
/// </pre>
/// </example>
public static int Pienempi(int a, int b)
{
if (a <= b) return a;
return b;
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ExternalConsole>true</ExternalConsole>
</PropertyGroup>
</Project>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using static Lukuja;
[TestFixture]
[DefaultFloatingPointTolerance(0.000001)]
public class TestLukuja
{
[Test]
public void TestSuurempi44()
{
Assert.AreEqual( 4, Suurempi(3, 4) , "in method Suurempi, line 45");
Assert.AreEqual( 7, Suurempi(7, 5) , "in method Suurempi, line 46");
Assert.AreEqual( 6, Suurempi(6, 6) , "in method Suurempi, line 47");
}
[Test]
public void TestPienempi64()
{
Assert.AreEqual( 3, Pienempi(3, 4) , "in method Pienempi, line 65");
Assert.AreEqual( 5, Pienempi(7, 5) , "in method Pienempi, line 66");
Assert.AreEqual( 6, Pienempi(6, 6) , "in method Pienempi, line 67");
}
}
<?xml version="1.0" encoding="UTF-8"?><Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.1"/>
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lukuja\Lukuja.csproj"/>
</ItemGroup>
</Project>
using System;
/// @author Vesa Lappalainen
/// @version 29.09.2012
///
/// <summary>
/// Tutkitaan mitä merkkijonoilla voi tehdä
/// </summary>
public class Merkkijonoja
{
public static void Main()
{
// tyyppi muuttuja = arvo;
int i = 5;
string mj = "Matti"; // 01234
int pituus = mj.Length;
Console.WriteLine(pituus); // 5
string mjPienena = mj.ToLower();
Console.WriteLine(mjPienena); // matti
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ExternalConsole>true</ExternalConsole>
</PropertyGroup>
</Project>

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32819.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lukuja", "Lukuja\Lukuja.csproj", "{07977CBD-B2F1-4B8C-9D0F-7A310DA7BE92}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Merkkijonoja", "Merkkijonoja\Merkkijonoja.csproj", "{B8932A3D-8E35-46F6-A766-5FFB2DFA4B70}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LukujaTest", "LukujaTest\LukujaTest.csproj", "{4429BD0E-8C5A-4154-A500-AF0A3D7619CD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{07977CBD-B2F1-4B8C-9D0F-7A310DA7BE92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07977CBD-B2F1-4B8C-9D0F-7A310DA7BE92}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07977CBD-B2F1-4B8C-9D0F-7A310DA7BE92}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07977CBD-B2F1-4B8C-9D0F-7A310DA7BE92}.Release|Any CPU.Build.0 = Release|Any CPU
{B8932A3D-8E35-46F6-A766-5FFB2DFA4B70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8932A3D-8E35-46F6-A766-5FFB2DFA4B70}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8932A3D-8E35-46F6-A766-5FFB2DFA4B70}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8932A3D-8E35-46F6-A766-5FFB2DFA4B70}.Release|Any CPU.Build.0 = Release|Any CPU
{4429BD0E-8C5A-4154-A500-AF0A3D7619CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4429BD0E-8C5A-4154-A500-AF0A3D7619CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4429BD0E-8C5A-4154-A500-AF0A3D7619CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4429BD0E-8C5A-4154-A500-AF0A3D7619CD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6A8F3AF9-B220-42EA-8E5A-BB0DB7E6B63F}
EndGlobalSection
EndGlobal
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