diff --git a/demopohjat/demo8/.idea/.idea.Demo8/.idea/.gitignore b/demopohjat/demo8/.idea/.idea.Demo8/.idea/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..f3bbf8206dc273db311e2a519f40057bc2d1a090
--- /dev/null
+++ b/demopohjat/demo8/.idea/.idea.Demo8/.idea/.gitignore
@@ -0,0 +1,13 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Rider ignored files
+/modules.xml
+/projectSettingsUpdater.xml
+/.idea.Demo8.iml
+/contentModel.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/demopohjat/demo8/.idea/.idea.Demo8/.idea/.name b/demopohjat/demo8/.idea/.idea.Demo8/.idea/.name
new file mode 100644
index 0000000000000000000000000000000000000000..8d454d791da3dd7197ceb0efbe6e251812e1cdfc
--- /dev/null
+++ b/demopohjat/demo8/.idea/.idea.Demo8/.idea/.name
@@ -0,0 +1 @@
+Demo8
\ No newline at end of file
diff --git a/demopohjat/demo8/.idea/.idea.Demo8/.idea/encodings.xml b/demopohjat/demo8/.idea/.idea.Demo8/.idea/encodings.xml
new file mode 100644
index 0000000000000000000000000000000000000000..df87cf951fb4858ab7a76b68dd479c98b2df2404
--- /dev/null
+++ b/demopohjat/demo8/.idea/.idea.Demo8/.idea/encodings.xml
@@ -0,0 +1,4 @@
+<?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
diff --git a/demopohjat/demo8/.idea/.idea.Demo8/.idea/indexLayout.xml b/demopohjat/demo8/.idea/.idea.Demo8/.idea/indexLayout.xml
new file mode 100644
index 0000000000000000000000000000000000000000..7b08163cebc50fb3e777eea4881b68fcebc10590
--- /dev/null
+++ b/demopohjat/demo8/.idea/.idea.Demo8/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="UserContentModel">
+    <attachedFolders />
+    <explicitIncludes />
+    <explicitExcludes />
+  </component>
+</project>
\ No newline at end of file
diff --git a/demopohjat/demo8/.idea/.idea.Demo8/.idea/vcs.xml b/demopohjat/demo8/.idea/.idea.Demo8/.idea/vcs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..b2bdec2d71b6a5ce4ae49efc37516809c50e4d5e
--- /dev/null
+++ b/demopohjat/demo8/.idea/.idea.Demo8/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?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
diff --git a/demopohjat/demo8/Lampotilat/Lampotilat.cs b/demopohjat/demo8/Lampotilat/Lampotilat.cs
index 7901b345388b89e0f5fd32028c247041fe37e21c..28cef6d2026638617132c5721e993ae5370eba94 100644
--- a/demopohjat/demo8/Lampotilat/Lampotilat.cs
+++ b/demopohjat/demo8/Lampotilat/Lampotilat.cs
@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using MinJypeli;
 
 namespace Demo7
 {
@@ -95,7 +94,7 @@ namespace MinJypeli
     /// </summary>
     public static class RandomGen
     {
-        private static Random rand = new Random();
+        private static readonly Random rand = new Random();
 
         /// <summary>
         /// Palauttaa satunnaisen liukuluvun parametrien <code>min</code> ja <code>max</code> väliltä.
@@ -123,7 +122,7 @@ namespace MinJypeli
         }
     }
 
-    public struct Vector
+    public readonly struct Vector
     {
         /// <summary>
         /// Nollavektori.
@@ -142,24 +141,18 @@ namespace MinJypeli
             return Math.Sqrt((x * x + y * y));
         }
 
-        public double X;
-        public double Y;
+        public readonly double X;
+        public readonly double Y;
 
         /// <summary>
         /// Vektorin pituus.
         /// </summary>
-        public double Magnitude
-        {
-            get { return Math.Sqrt(MagnitudeSquared); }
-        }
+        public double Magnitude => Math.Sqrt(MagnitudeSquared);
 
         /// <summary>
         /// Vektorin pituuden neliö.
         /// </summary>
-        public double MagnitudeSquared
-        {
-            get { return X * X + Y * Y; }
-        }
+        public double MagnitudeSquared => X * X + Y * Y;
 
         /// <summary>
         /// Luo uuden vektorin komponenteista.
@@ -179,7 +172,7 @@ namespace MinJypeli
         /// <returns>lukupari merkkijonona</returns>
         public override string ToString()
         {
-            return String.Format("({0:0.0},{1:0.0})", X, Y);
+            return $"({X:0.0},{Y:0.0})";
         }
 
 
diff --git a/demopohjat/demo8/Pisteet/Pisteet.cs b/demopohjat/demo8/Pisteet/Pisteet.cs
index a2c4087a48f38a7fe2aed421db41b44851749d55..08024e28a41de771d44ac720100a2c74fa4a20a2 100644
--- a/demopohjat/demo8/Pisteet/Pisteet.cs
+++ b/demopohjat/demo8/Pisteet/Pisteet.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections.Generic;
 using MinJypeli;
 
 namespace Demo7
@@ -77,12 +76,12 @@ namespace Demo7
         /// Arvotaan joukko 2D-pisteitä halutulle alueelle
         /// </summary>
         /// <param name="n">montako pistettä arvotaan</param>
-        /// <param name="x1">alueen vasemman alakulman x</param>
-        /// <param name="y1">alueen vasemman alakulman y</param>
-        /// <param name="x2">alueen oikean yläkulman x</param>
-        /// <param name="y2">alueen oikean yläkulman y</param>
+        /// <param name="ax1">alueen vasemman alakulman x</param>
+        /// <param name="ay1">alueen vasemman alakulman y</param>
+        /// <param name="ax2">alueen oikean yläkulman x</param>
+        /// <param name="ay2">alueen oikean yläkulman y</param>
         /// <returns></returns>
-        public static Vector[] ArvoPisteet(int n, double x1, double y1, double x2, double y2)
+        public static Vector[] ArvoPisteet(int n, double ax1, double ay1, double ax2, double ay2)
         {
             // Tee n-kokoinen taulukko Vector-olioista.
             // Arvo kullekin alkiolle sattunnainen x ja y koordinaatti
@@ -92,8 +91,8 @@ namespace Demo7
             Vector[] pisteet = new Vector[n];
             for (int i = 0; i < pisteet.Length; i++)
             {
-                double x = RandomGen.NextDouble(x1, x2);
-                double y = RandomGen.NextDouble(y1, y2);
+                double x = RandomGen.NextDouble(ax1, ax2);
+                double y = RandomGen.NextDouble(ay1, ay2);
                 pisteet[i] = new Vector(x, y);
             }
             return pisteet;
@@ -185,13 +184,13 @@ namespace Demo7
         /// Tulostetaan annetusta taulukosta pisteitä 6 riviä.
         /// </summary>
         /// <param name="pistetaulukko">tulostettavien pisteiden koordinaatteja taulukossa</param>
-        public static void TulostaTaulukosta2(Vector[] pistetaulukko2)
+        public static void TulostaTaulukosta2(Vector[] pistetaulukko)
         {
-            if (pistetaulukko2.Length < 7) return;
+            if (pistetaulukko.Length < 7) return;
             Console.WriteLine("Tässä tulostetaan taulukosta pisteitä 3 kappaletta");
             for (int i = 0; i < 7; i++)
             {
-                Console.WriteLine(pistetaulukko2[i]);
+                Console.WriteLine(pistetaulukko[i]);
             }
 
         }
@@ -206,7 +205,7 @@ namespace MinJypeli
     /// </summary>
     public static class RandomGen
     {
-        private static Random rand = new Random();
+        private static readonly Random rand = new Random();
 
         /// <summary>
         /// Palauttaa satunnaisen liukuluvun parametrien <code>min</code> ja <code>max</code> väliltä.
@@ -234,7 +233,7 @@ namespace MinJypeli
         }
     }
 
-    public struct Vector
+    public readonly struct Vector
     {
         /// <summary>
         /// Nollavektori.
@@ -253,24 +252,18 @@ namespace MinJypeli
             return Math.Sqrt((x * x + y * y));
         }
 
-        public double X;
-        public double Y;
+        public readonly double X;
+        public readonly double Y;
 
         /// <summary>
         /// Vektorin pituus.
         /// </summary>
-        public double Magnitude
-        {
-            get { return Math.Sqrt(MagnitudeSquared); }
-        }
+        public double Magnitude => Math.Sqrt(MagnitudeSquared);
 
         /// <summary>
         /// Vektorin pituuden neliö.
         /// </summary>
-        public double MagnitudeSquared
-        {
-            get { return X * X + Y * Y; }
-        }
+        public double MagnitudeSquared => X * X + Y * Y;
 
         /// <summary>
         /// Luo uuden vektorin komponenteista.
@@ -290,7 +283,7 @@ namespace MinJypeli
         /// <returns>lukupari merkkijonona</returns>
         public override string ToString()
         {
-            return String.Format("({0:0.0},{1:0.0})", X, Y);
+            return $"({X:0.0},{Y:0.0})";
         }
 
 
diff --git a/demopohjat/demo8/Pisteet2/Pisteet2.cs b/demopohjat/demo8/Pisteet2/Pisteet2.cs
index 97cdb6ce3e52b6f88febca7065f6d75e54034d88..b5d6f3876646ea3c34ce5faf83fd2770fb2d3ce9 100644
--- a/demopohjat/demo8/Pisteet2/Pisteet2.cs
+++ b/demopohjat/demo8/Pisteet2/Pisteet2.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections.Generic;
 using MinJypeli;
 
 namespace Demo7
@@ -96,12 +95,12 @@ namespace Demo7
         /// Arvotaan joukko 2D-pisteitä halutulle alueelle
         /// </summary>
         /// <param name="n">montako pistettä arvotaan</param>
-        /// <param name="x1">alueen vasemman alakulman x</param>
-        /// <param name="y1">alueen vasemman alakulman y</param>
-        /// <param name="x2">alueen oikean yläkulman x</param>
-        /// <param name="y2">alueen oikean yläkulman y</param>
+        /// <param name="ax1">alueen vasemman alakulman x</param>
+        /// <param name="ay1">alueen vasemman alakulman y</param>
+        /// <param name="ax2">alueen oikean yläkulman x</param>
+        /// <param name="ay2">alueen oikean yläkulman y</param>
         /// <returns></returns>
-        public static Vector[] ArvoPisteet(int n, double x1, double y1, double x2, double y2)
+        public static Vector[] ArvoPisteet(int n, double ax1, double ay1, double ax2, double ay2)
         {
             // Tee n-kokoinen taulukko Vector-olioista.
             // Arvo kullekin alkiolle sattunnainen x ja y koordinaatti
@@ -111,8 +110,8 @@ namespace Demo7
             Vector[] pisteet = new Vector[n];
             for (int i = 0; i < pisteet.Length; i++)
             {
-                double x = RandomGen.NextDouble(x1, x2);
-                double y = RandomGen.NextDouble(y1, y2);
+                double x = RandomGen.NextDouble(ax1, ax2);
+                double y = RandomGen.NextDouble(ay1, ay2);
                 pisteet[i] = new Vector(x, y);
             }
             return pisteet;
diff --git a/demopohjat/demo8/Tauno8/Tauno8.cs b/demopohjat/demo8/Tauno8/Tauno8.cs
index d99ec1997ba6005a267472d4b71a94e601fe4c13..d43571538ef7aa380400d9534516d1d26d91f31a 100644
--- a/demopohjat/demo8/Tauno8/Tauno8.cs
+++ b/demopohjat/demo8/Tauno8/Tauno8.cs
@@ -1,7 +1,4 @@
 using System;
-using System.Text;
-using System.Linq;
-using System.Collections.Generic;
 
 /// @author vesal
 /// @version 26.10.2013
diff --git a/demopohjat/demo9/.idea/.idea.demo9/.idea/.gitignore b/demopohjat/demo9/.idea/.idea.demo9/.idea/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..94096b4d247ea871bece72a88476b70ef8fc4ddf
--- /dev/null
+++ b/demopohjat/demo9/.idea/.idea.demo9/.idea/.gitignore
@@ -0,0 +1,13 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Rider ignored files
+/contentModel.xml
+/.idea.demo9.iml
+/projectSettingsUpdater.xml
+/modules.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/demopohjat/demo9/.idea/.idea.demo9/.idea/encodings.xml b/demopohjat/demo9/.idea/.idea.demo9/.idea/encodings.xml
new file mode 100644
index 0000000000000000000000000000000000000000..df87cf951fb4858ab7a76b68dd479c98b2df2404
--- /dev/null
+++ b/demopohjat/demo9/.idea/.idea.demo9/.idea/encodings.xml
@@ -0,0 +1,4 @@
+<?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
diff --git a/demopohjat/demo9/.idea/.idea.demo9/.idea/indexLayout.xml b/demopohjat/demo9/.idea/.idea.demo9/.idea/indexLayout.xml
new file mode 100644
index 0000000000000000000000000000000000000000..7b08163cebc50fb3e777eea4881b68fcebc10590
--- /dev/null
+++ b/demopohjat/demo9/.idea/.idea.demo9/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="UserContentModel">
+    <attachedFolders />
+    <explicitIncludes />
+    <explicitExcludes />
+  </component>
+</project>
\ No newline at end of file
diff --git a/demopohjat/demo9/.idea/.idea.demo9/.idea/vcs.xml b/demopohjat/demo9/.idea/.idea.demo9/.idea/vcs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..b2bdec2d71b6a5ce4ae49efc37516809c50e4d5e
--- /dev/null
+++ b/demopohjat/demo9/.idea/.idea.demo9/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?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
diff --git a/demopohjat/demo9/Kuva/Kuva.cs b/demopohjat/demo9/Kuva/Kuva.cs
index cc21fdb3d11d4b2a2dfe1f3da0ea2a508d3f8136..85c705713f3df59609b31f4d9a85d18005dd4a12 100644
--- a/demopohjat/demo9/Kuva/Kuva.cs
+++ b/demopohjat/demo9/Kuva/Kuva.cs
@@ -26,7 +26,7 @@ namespace Demo9;
 /// 
 public class Kuva : PhysicsGame
 {
-    private string kuvannimi = "vesa";
+    private readonly string kuvannimi = "vesa";
 
     /// <summary>
     /// Tehdään kuvalle erilaisia operaatioita ja näytetään kuvat
@@ -40,7 +40,7 @@ public class Kuva : PhysicsGame
         Level.Width = 2 * kuva.Width;
         Level.Height = 2 * kuva.Height;
 
-        AddKuva(kuva, 0, 0);
+        AddKuva(kuva);
 
         Image kuva2 = kuva.Clone();
         HarmaasavyTaulukolla(kuva2);
@@ -52,7 +52,7 @@ public class Kuva : PhysicsGame
 
         Image kuva3 = kuva.Clone();
         Punaiseksi(kuva3);
-        AddKuva(kuva3, 1, 0);
+        AddKuva(kuva3, 1);
 
         Image kuva4 = Konvoluutio(kuvannimi, painot);
         AddKuva(kuva4, 1, 1);
diff --git a/demopohjat/demo9/Palapeli/Palapeli.cs b/demopohjat/demo9/Palapeli/Palapeli.cs
index bc43ba4915e6d3be831e1334b4e600224982c2f7..9fe8aa9f9b7092796a1ff395b301e09aedca8f62 100644
--- a/demopohjat/demo9/Palapeli/Palapeli.cs
+++ b/demopohjat/demo9/Palapeli/Palapeli.cs
@@ -11,10 +11,10 @@ namespace Demo9;
 public class Palapeli : PhysicsGame
 {
     private const int siirtymaNopeus = 500;
-    private Vector ensimmaisenPalanPaikka = new Vector(-200, 150);
+    private readonly Vector ensimmaisenPalanPaikka = new Vector(-200, 150);
 
     private List<GameObject> palat;
-    private GameObject odotuspaikalla = null;
+    private GameObject odotuspaikalla;
     private Vector vapaapaikka;
     private Vector odotuspaikka;
 
@@ -58,7 +58,7 @@ public class Palapeli : PhysicsGame
         Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Exit game");
 
         Mouse.IsCursorVisible = true;
-        Mouse.Listen(MouseButton.Left, ButtonState.Pressed, delegate () { ValitseKuva(Mouse.PositionOnWorld); }, "Valitse kuva");
+        Mouse.Listen(MouseButton.Left, ButtonState.Pressed, delegate { ValitseKuva(Mouse.PositionOnWorld); }, "Valitse kuva");
     }
 
 
@@ -135,7 +135,7 @@ public class Palapeli : PhysicsGame
     public static List<GameObject> LisaaPalatRuutuun(Game peli, List<Image> kuvat, int nx, int ny, Vector aloitus)
     {
 
-        /// TODO: Tehtävä 6-7: Korjaa kunnolla toimivaksi, nyt laittaa vain kolme palaa.
+        // TODO: Tehtävä 6-7: Korjaa kunnolla toimivaksi, nyt laittaa vain kolme palaa.
         List<GameObject> palat = new List<GameObject>();
         GameObject palanen;
 
diff --git a/demopohjat/demo9/PortaatKonsolilla/PortaatKonsolilla.cs b/demopohjat/demo9/PortaatKonsolilla/PortaatKonsolilla.cs
index 50c124a7449650b47ebdce486cb093471e2de8c9..92b2f23002c56fdc1db3c3fd2149bdd44f76a316 100644
--- a/demopohjat/demo9/PortaatKonsolilla/PortaatKonsolilla.cs
+++ b/demopohjat/demo9/PortaatKonsolilla/PortaatKonsolilla.cs
@@ -4,32 +4,42 @@ using MinJypeli;
 
 namespace Demo9
 {
+    /// @author  Vesa Lappalainen
+    /// @author  Enni Stylman
+    /// @author  Aleksi Tarvainen
+    /// @version 3.11.2019
     public class PortaatKonsolilla
     {
-        public static List<Shape> layer = new List<Shape> { };
-        public static double LAATIKON_KOKO = 40.0;
+        public const double LAATIKON_KOKO = 40.0;
 
         /// BYCODEBEGIN
         public static void Main()
         {
+            List<Shape> layer = new List<Shape>();
             Vector piste = new Vector(0, 0);
-            piste = PiirraLaatikko(piste);
-            piste = PiirraLaatikko(piste);
-            piste = PiirraLaatikko(piste);
+            // Poista kommentit
+            // piste = PiirraLaatikko(layer, piste);
+            // piste = PiirraLaatikko(layer, piste);
+            // piste = PiirraLaatikko(layer, piste);
+            Console.WriteLine("Loppupiste: " + piste);
             Console.WriteLine("Laatikoiden vasemmat alakulmat ja oikeat yläkulmat:");
             Print(layer);
         }
 
+        // Ota pois kommenteista ja korvaa ???
+        /*
         public static ??? PiirraLaatikko(???)
         {
             double s = LAATIKON_KOKO;
-            Rectangle nelio = new Rectangle()
-            nelio.Position = ???
+            Rectangle nelio = new Rectangle(???);
+            nelio.Position = ???;
             layer.Add(nelio);
             ???
         }
+        */
         /// BYCODEEND
 
+        
         /// <summary>
         ///  Tulostaa kunkin muodon vasemman alakulman koordinaatit ja oikean yläkulman koordinaatit
         /// </summary>
@@ -43,19 +53,24 @@ namespace Demo9
     }
 }
 
-/// @author  Vesa Lappalainen
-/// @author  Enni Stylman
-/// @author  Aleksi Tarvainen
-/// @version 3.11.2019
+
+// ReSharper disable ArrangeAccessorOwnerBody
 namespace MinJypeli
 {
-
     /// <summary>
     /// Kantaluokka kaksiulotteisille muodoille
     /// </summary>
     public abstract class Shape
     {
+        public readonly double Width;
+        public readonly double Height;
         public Vector Position = Vector.Zero;
+
+        protected Shape(double width, double height)
+        {
+            Width = width;
+            Height = height;
+        }
         public double X
         {
             get { return Position.X; }
@@ -68,38 +83,30 @@ namespace MinJypeli
             set { Position = new Vector(X, value); }
         }
 
-        public virtual double Left { get; }
-        public virtual double Right { get; }
-        public virtual double Top { get; }
-        public virtual double Bottom { get; }
+        public virtual double Left { get { return X - Width / 2; } }
+        public virtual double Right { get { return X + Width / 2; } }
+        public virtual double Top { get { return Y + Height / 2; } }
+        public virtual double Bottom { get { return Y - Height / 2; } }
     }
 
+    
     /// <summary>
     /// Tavallinen suorakulmio
     /// </summary>
     public class Rectangle : Shape
     {
-        public double Width;
-        public double Height;
-        public Rectangle(double width, double height, Vector pos = new Vector())
+        public Rectangle(double width, double height): base(width, height)
         {
-            Width = width;
-            Height = height;
-            Position = pos;
         }
-
-        public override double Left { get { return X - Width / 2; } }
-        public override double Right { get { return X + Width / 2; } }
-        public override double Top { get { return Y + Height / 2; } }
-        public override double Bottom { get { return Y - Height / 2; } }
     }
 
+    
     /// <summary>
     /// Satunnaisgeneraattori. Luo satunnaisia arvoja, mm. lukuja, vektoreita sekä kulmia.
     /// </summary>
     public static class RandomGen
     {
-        private static Random rand = new Random();
+        private static readonly Random rand = new Random();
 
         /// <summary>
         /// Palauttaa satunnaisen liukuluvun parametrien <code>min</code> ja <code>max</code> väliltä.
@@ -127,6 +134,7 @@ namespace MinJypeli
         }
     }
 
+    
     public struct Vector
     {
         /// <summary>
@@ -183,7 +191,7 @@ namespace MinJypeli
         /// <returns>lukupari merkkijonona</returns>
         public override string ToString()
         {
-            return String.Format("({0:0.0},{1:0.0})", X, Y);
+            return $"({X:0.0},{Y:0.0})";
         }
 
 
diff --git a/demopohjat/demo9/PortaatYlosAlas/PortaatYlosAlas.cs b/demopohjat/demo9/PortaatYlosAlasKonsolilla/PortaatYlosAlasKonsolilla.cs
similarity index 69%
rename from demopohjat/demo9/PortaatYlosAlas/PortaatYlosAlas.cs
rename to demopohjat/demo9/PortaatYlosAlasKonsolilla/PortaatYlosAlasKonsolilla.cs
index 5e676dc11f6b0bf3e9be1b87a2866d216e27920b..4bdc465fc2c7db5f96b1f7ef9b8f0dd50e5554a2 100644
--- a/demopohjat/demo9/PortaatYlosAlas/PortaatYlosAlas.cs
+++ b/demopohjat/demo9/PortaatYlosAlasKonsolilla/PortaatYlosAlasKonsolilla.cs
@@ -4,34 +4,41 @@ using MinJypeli;
 
 namespace Demo9
 {
-    public class PortaatYlosAlas
+    /// @author  Vesa Lappalainen
+    /// @author  Enni Stylman
+    /// @author  Aleksi Tarvainen
+    /// @version 3.11.2019
+    public class PortaatYlosAlasKonsolilla
     {
-        public static List<Shape> layer = new List<Shape> { };
-        public static double LAATIKON_KOKO = 40.0;
+        public const double LAATIKON_KOKO = 40.0;
 
         /// BYCODEBEGIN
         public static void Main()
         {
+            List<Shape> layer = new List<Shape>();
             Vector piste = new Vector(0, 0);
-            piste = PiirraLaatikko(piste);
-            piste = PiirraLaatikko(piste);
-            piste = PiirraLaatikko(piste);
-            piste -= new Vector(0, LAATIKON_KOKO);
-            piste = PiirraLaatikkoAlas(piste);
-            piste = PiirraLaatikkoAlas(piste);
-
+            // poista kommentit
+            // piste = PiirraLaatikko(layer, piste);
+            // piste = PiirraLaatikko(layer, piste);
+            // piste = PiirraLaatikko(layer, piste);
+            // piste -= new Vector(0, LAATIKON_KOKO);
+            // piste = PiirraLaatikkoAlas(layer, piste);
+            // piste = PiirraLaatikkoAlas(layer, piste);
+            Console.WriteLine("Loppupiste: " + piste);
             Console.WriteLine("Laatikoiden vasemmat alakulmat ja oikeat yläkulmat:");
             Print(layer);
         }
 
+        
         // TODO: Kopioi tähän edellisen tehtävän aliohjelma PiirraLaatikko
         // TODO: Määrittele uusi aliohjelma PiirraLaatikkoAlas, jotta ohjelma toimii
         // TODO: Täysiä pisteitä varten määrittele myös aliohjelma PiirraPortaat,
         // jolle viedään parametrina, mistä pisteestä portaiden luominen aloitetaan
         // ja montako porrasta tulee ylös ja montako alas.
-
+        //
         /// BYCODEEND
 
+        
         /// <summary>
         ///  Tulostaa kunkin muodon vasemman alakulman koordinaatit ja oikean yläkulman koordinaatit
         /// </summary>
@@ -45,19 +52,24 @@ namespace Demo9
     }
 }
 
-/// @author  Vesa Lappalainen
-/// @author  Enni Stylman
-/// @author  Aleksi Tarvainen
-/// @version 3.11.2019
+
+// ReSharper disable ArrangeAccessorOwnerBody
 namespace MinJypeli
 {
-
     /// <summary>
     /// Kantaluokka kaksiulotteisille muodoille
     /// </summary>
     public abstract class Shape
     {
+        public readonly double Width;
+        public readonly double Height;
         public Vector Position = Vector.Zero;
+
+        protected Shape(double width, double height)
+        {
+            Width = width;
+            Height = height;
+        }
         public double X
         {
             get { return Position.X; }
@@ -70,38 +82,30 @@ namespace MinJypeli
             set { Position = new Vector(X, value); }
         }
 
-        public virtual double Left { get; }
-        public virtual double Right { get; }
-        public virtual double Top { get; }
-        public virtual double Bottom { get; }
+        public virtual double Left { get { return X - Width / 2; } }
+        public virtual double Right { get { return X + Width / 2; } }
+        public virtual double Top { get { return Y + Height / 2; } }
+        public virtual double Bottom { get { return Y - Height / 2; } }
     }
 
+    
     /// <summary>
     /// Tavallinen suorakulmio
     /// </summary>
     public class Rectangle : Shape
     {
-        public double Width;
-        public double Height;
-        public Rectangle(double width, double height, Vector pos = new Vector())
+        public Rectangle(double width, double height): base(width, height)
         {
-            Width = width;
-            Height = height;
-            Position = pos;
         }
-
-        public override double Left { get { return X - Width / 2; } }
-        public override double Right { get { return X + Width / 2; } }
-        public override double Top { get { return Y + Height / 2; } }
-        public override double Bottom { get { return Y - Height / 2; } }
     }
 
+    
     /// <summary>
     /// Satunnaisgeneraattori. Luo satunnaisia arvoja, mm. lukuja, vektoreita sekä kulmia.
     /// </summary>
     public static class RandomGen
     {
-        private static Random rand = new Random();
+        private static readonly Random rand = new Random();
 
         /// <summary>
         /// Palauttaa satunnaisen liukuluvun parametrien <code>min</code> ja <code>max</code> väliltä.
@@ -129,6 +133,7 @@ namespace MinJypeli
         }
     }
 
+    
     public struct Vector
     {
         /// <summary>
@@ -185,7 +190,7 @@ namespace MinJypeli
         /// <returns>lukupari merkkijonona</returns>
         public override string ToString()
         {
-            return String.Format("({0:0.0},{1:0.0})", X, Y);
+            return $"({X:0.0},{Y:0.0})";
         }
 
 
@@ -228,5 +233,35 @@ namespace MinJypeli
         {
             return new Vector(a.X - b.X, a.Y - b.Y);
         }
+
+        /// <summary>
+        /// Kertoo vektorin skalaarilla
+        /// </summary>
+        /// <param name="source">Kerrottava vektori</param>
+        /// <param name="scalar">Arvo jolla vektori kerrotaan</param>
+        /// <returns>Vektorin skaalauksen tulos</returns>
+        /// <remarks><seealso href="http://en.wikipedia.org/wiki/Vector_%28spatial%29#Scalar_multiplication"/></remarks>
+        public static Vector operator *(Vector source, double scalar)
+        {
+            Vector result;
+            result.X = source.X * scalar;
+            result.Y = source.Y * scalar;
+            return result;
+        }
+
+        /// <summary>
+        /// Kertoo vektorin skalaarilla
+        /// </summary>
+        /// <param name="source">Kerrottava vektori</param>
+        /// <param name="scalar">Arvo jolla vektori kerrotaan</param>
+        /// <returns>Vektorin skaalauksen tulos</returns>
+        /// <remarks><seealso href="http://en.wikipedia.org/wiki/Vector_%28spatial%29#Scalar_multiplication"/></remarks>
+        public static Vector operator *(double scalar, Vector source)
+        {
+            Vector result;
+            result.X = scalar * source.X;
+            result.Y = scalar * source.Y;
+            return result;
+        }
     }
 }
\ No newline at end of file
diff --git a/demopohjat/demo9/PortaatYlosAlas/PortaatYlosAlas.csproj b/demopohjat/demo9/PortaatYlosAlasKonsolilla/PortaatYlosAlasKonsolilla.csproj
similarity index 99%
rename from demopohjat/demo9/PortaatYlosAlas/PortaatYlosAlas.csproj
rename to demopohjat/demo9/PortaatYlosAlasKonsolilla/PortaatYlosAlasKonsolilla.csproj
index 1ded6129c11699cbd369da98d357d580dc73ec26..df22a1ba07d539b07cf0adbaa6457daadeb433db 100644
--- a/demopohjat/demo9/PortaatYlosAlas/PortaatYlosAlas.csproj
+++ b/demopohjat/demo9/PortaatYlosAlasKonsolilla/PortaatYlosAlasKonsolilla.csproj
@@ -7,4 +7,3 @@
     </PropertyGroup>
 
 </Project>
-
diff --git a/demopohjat/demo9/VarienVaihtoKonsolilla/VarienVaihtoKonsolilla.cs b/demopohjat/demo9/VarienVaihtoKonsolilla/VarienVaihtoKonsolilla.cs
index e15417236386fd8b37744f7914a559111410a28d..170b86fce67cb9a5c05c41ca9e9fd14e10d64f82 100644
--- a/demopohjat/demo9/VarienVaihtoKonsolilla/VarienVaihtoKonsolilla.cs
+++ b/demopohjat/demo9/VarienVaihtoKonsolilla/VarienVaihtoKonsolilla.cs
@@ -1,7 +1,4 @@
 using System;
-using System.Text;
-using System.Linq;
-using System.Collections.Generic;
 using Demo9;
 
 /// @author Aleksi Tarvainen
@@ -12,8 +9,9 @@ using Demo9;
 public class VarienVaihtoKonsolilla
 {
     /// <summary>
-    /// 
+    /// Vaihdetaan liian siniset pikselit harmaiksi 
     /// </summary>
+    // BYCODEBEGIN
     public static void Main()
     {
         uint[,] kuva = {
@@ -23,16 +21,18 @@ public class VarienVaihtoKonsolilla
         };
         Console.WriteLine("Ennen muunnosta:");
         TulostaKuva(kuva);
-        byte raja = 130;
-        SininenHarmaaksi(kuva, raja);
+        // Poista kommentit
+        // byte raja = 130;
+        // SininenHarmaaksi(kuva, raja);
         Console.WriteLine("\nMuunnoksen jälkeen:");
         TulostaKuva(kuva);
     }
 
-    // BYCODEBEGIN
-
-
+    
+    // Toteuta tarvittava aliohjema tähän
     // BYCODEEND
+
+    
     private static void TulostaKuva(uint[,] kuva)
     {
         for (int i = 0; i < kuva.GetLength(0); i++)
diff --git a/demopohjat/demo9/demo9.sln b/demopohjat/demo9/demo9.sln
index 63f1ab44fbace1e4e012cf4804e3440dae715054..83cbde4a0059edfc151e860f30c107cccad52ebb 100644
--- a/demopohjat/demo9/demo9.sln
+++ b/demopohjat/demo9/demo9.sln
@@ -9,10 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kuva", "Kuva\Kuva.csproj",
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PortaatKonsolilla", "PortaatKonsolilla\PortaatKonsolilla.csproj", "{5A75ED38-34D0-4F37-8236-1E36B63B102E}"
 EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PortaatYlosAlas", "PortaatYlosAlas\PortaatYlosAlas.csproj", "{1E8ECCEE-32F5-450E-8BA9-4E686F72F69D}"
-EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VarienVaihtoKonsolilla", "VarienVaihtoKonsolilla\VarienVaihtoKonsolilla.csproj", "{26E4CFF0-0F9E-4402-B9AC-7C4129DBEF8F}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortaatYlosAlasKonsolilla", "PortaatYlosAlasKonsolilla\PortaatYlosAlasKonsolilla.csproj", "{CE21768D-76C1-40D6-B875-89051B14486C}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -31,14 +31,14 @@ Global
 		{5A75ED38-34D0-4F37-8236-1E36B63B102E}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{5A75ED38-34D0-4F37-8236-1E36B63B102E}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{5A75ED38-34D0-4F37-8236-1E36B63B102E}.Release|Any CPU.Build.0 = Release|Any CPU
-		{1E8ECCEE-32F5-450E-8BA9-4E686F72F69D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{1E8ECCEE-32F5-450E-8BA9-4E686F72F69D}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{1E8ECCEE-32F5-450E-8BA9-4E686F72F69D}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{1E8ECCEE-32F5-450E-8BA9-4E686F72F69D}.Release|Any CPU.Build.0 = Release|Any CPU
 		{26E4CFF0-0F9E-4402-B9AC-7C4129DBEF8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{26E4CFF0-0F9E-4402-B9AC-7C4129DBEF8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{26E4CFF0-0F9E-4402-B9AC-7C4129DBEF8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{26E4CFF0-0F9E-4402-B9AC-7C4129DBEF8F}.Release|Any CPU.Build.0 = Release|Any CPU
+		{CE21768D-76C1-40D6-B875-89051B14486C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{CE21768D-76C1-40D6-B875-89051B14486C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{CE21768D-76C1-40D6-B875-89051B14486C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{CE21768D-76C1-40D6-B875-89051B14486C}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE