From 655eca3ccf7d02af4a8f33105e8e2579a03acb86 Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Thu, 14 Nov 2024 14:17:34 +0100 Subject: [PATCH] Mer random --- Emne 3/ConsoleApp5/Random/Program.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Emne 3/ConsoleApp5/Random/Program.cs b/Emne 3/ConsoleApp5/Random/Program.cs index 1bb970e..2e3d7f7 100644 --- a/Emne 3/ConsoleApp5/Random/Program.cs +++ b/Emne 3/ConsoleApp5/Random/Program.cs @@ -1,22 +1,25 @@ using System; namespace Random { - class Random + class RandomHobby { static void Main(string[] args) { System.Random rnd = new System.Random(); int randomnr = rnd.Next(0, 3); + Console.WriteLine("Hvem trenger en ny hobby? "); + string name = Console.ReadLine(); + if (randomnr == 0) { - Console.WriteLine("Tallet ble 0"); + Console.WriteLine($"{name} har nå hobbyen å strikke"); }else if (randomnr == 1) { - Console.WriteLine("Tallet ble 1"); + Console.WriteLine($"{name} er nå glad i å tegne"); } else { - Console.WriteLine("Tallet ble 2"); + Console.WriteLine($"{name} driver nå med Texas Hold-em"); } } }