diff --git a/Emne 3/Constructors/Constructors.sln b/Emne 3/Constructors/Constructors.sln new file mode 100644 index 0000000..09c0688 --- /dev/null +++ b/Emne 3/Constructors/Constructors.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Constructors", "Constructors\Constructors.csproj", "{E8126D7B-F007-4E3D-8A8C-473B25A5CFE6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E8126D7B-F007-4E3D-8A8C-473B25A5CFE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E8126D7B-F007-4E3D-8A8C-473B25A5CFE6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E8126D7B-F007-4E3D-8A8C-473B25A5CFE6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E8126D7B-F007-4E3D-8A8C-473B25A5CFE6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Emne 3/Pokemon/Pokemon.csproj b/Emne 3/Constructors/Constructors/Constructors.csproj similarity index 100% rename from Emne 3/Pokemon/Pokemon.csproj rename to Emne 3/Constructors/Constructors/Constructors.csproj diff --git a/Emne 3/Constructors/Constructors/Program.cs b/Emne 3/Constructors/Constructors/Program.cs new file mode 100644 index 0000000..6a00a91 --- /dev/null +++ b/Emne 3/Constructors/Constructors/Program.cs @@ -0,0 +1,22 @@ +namespace Constructors +{ + public class Person + { + public String Name { get; set; } + public int Age { get; set; } + + public Person(String name, Int32 age) + { + Name = name; + Age = age; + } + } + class Program + { + static void Main(string[] args) + { + var person1 = new Person("John", 19); + Console.WriteLine($"Navn: {person1.Name}, Alder: {person1.Age}"); + } + } +} \ No newline at end of file diff --git a/Emne 3/ObjekterIListe/ObjekterIListe.sln b/Emne 3/ObjekterIListe/ObjekterIListe.sln new file mode 100644 index 0000000..a4a4103 --- /dev/null +++ b/Emne 3/ObjekterIListe/ObjekterIListe.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObjekterIListe", "ObjekterIListe\ObjekterIListe.csproj", "{F05F887B-9700-40F0-BB06-7B90A67E1057}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F05F887B-9700-40F0-BB06-7B90A67E1057}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F05F887B-9700-40F0-BB06-7B90A67E1057}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F05F887B-9700-40F0-BB06-7B90A67E1057}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F05F887B-9700-40F0-BB06-7B90A67E1057}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Emne 3/ObjekterIListe/ObjekterIListe/ObjekterIListe.csproj b/Emne 3/ObjekterIListe/ObjekterIListe/ObjekterIListe.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/Emne 3/ObjekterIListe/ObjekterIListe/ObjekterIListe.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Emne 3/ObjekterIListe/ObjekterIListe/Person.cs b/Emne 3/ObjekterIListe/ObjekterIListe/Person.cs new file mode 100644 index 0000000..6910747 --- /dev/null +++ b/Emne 3/ObjekterIListe/ObjekterIListe/Person.cs @@ -0,0 +1,16 @@ +namespace ObjekterIListe; + +public class Person +{ + public string FirstName { get; set; } + public string LastName { get; set; } + public int Age { get; set; } + + // Constructor + public Person(string firstName, string lastName, int Age) + { + firstName = firstName; + lastName = lastName; + Age = Age; + } +} \ No newline at end of file diff --git a/Emne 3/ObjekterIListe/ObjekterIListe/Program.cs b/Emne 3/ObjekterIListe/ObjekterIListe/Program.cs new file mode 100644 index 0000000..af66958 --- /dev/null +++ b/Emne 3/ObjekterIListe/ObjekterIListe/Program.cs @@ -0,0 +1,29 @@ +namespace ObjekterIListe +{ + class Program + { + static public void AddPeople() + { + List people = new List(); + Person person1 = new Person("Alice", "Smith", 25); + Person person2 = new Person("Bob", "Jones", 37); + Person person3 = new Person("Charlie", "Jones", 28); + + people.Add(person1); + people.Add(person2); + people.Add(person3); + WriteToConsole(people); + + } + static void WriteToConsole(this List people) + { + for (int i = 0; i < people.Count; i++) + { + Console.WriteLine($"Fornavn: {people[i].FirstName}\nEtternavn: {people[i].LastName}\nAlder: {people[i].Age}"); + } + } + static void Main(string[] args){ + AddPeople(); + } + } +} \ No newline at end of file diff --git a/Emne 3/Pokedex/Pokedex.csproj b/Emne 3/Pokedex/Pokedex.csproj new file mode 100644 index 0000000..fa86969 --- /dev/null +++ b/Emne 3/Pokedex/Pokedex.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + enable + enable + Pokemon + + + diff --git a/Emne 3/Pokemon/Pokemon.sln b/Emne 3/Pokedex/Pokemon.sln similarity index 100% rename from Emne 3/Pokemon/Pokemon.sln rename to Emne 3/Pokedex/Pokemon.sln diff --git a/Emne 3/Pokedex/Program.cs b/Emne 3/Pokedex/Program.cs new file mode 100644 index 0000000..9d6efb8 --- /dev/null +++ b/Emne 3/Pokedex/Program.cs @@ -0,0 +1,22 @@ +using System; +namespace Pokedex +{ + // 1/3 Planning + // 1/6 Coding + // 1/4 component test and early system test + // 1/4 system test, all components in hand + // - "The Mythical Man Month" by Frederick P. Brooks + + class Program + { + static void Main(string[] args) + { + var pikachu = new Pokemon("Pikachu", 10, 30); + Console.WriteLine($"{pikachu.Name} har {pikachu.Health} hp og er level {pikachu.Level}"); + + var bulbasaur = new Pokemon("Bulbasaur",20, 90); + Console.WriteLine($"{bulbasaur.Name} har {bulbasaur.Health} hp og er level {bulbasaur.Level}"); + } + } +} + diff --git a/Emne 3/Pokedex/pokedex.cs b/Emne 3/Pokedex/pokedex.cs new file mode 100644 index 0000000..dd55bb8 --- /dev/null +++ b/Emne 3/Pokedex/pokedex.cs @@ -0,0 +1,15 @@ +namespace Pokedex; + +public class Pokemon +{ + internal int Health; + internal int Level; + internal string Name; + + public Pokemon(string name, int level, int health) + { + Name = name; + Level = level; + Health = health; + } +} \ No newline at end of file diff --git a/Emne 3/Pokemon/Program.cs b/Emne 3/Pokemon/Program.cs deleted file mode 100644 index 62c0002..0000000 --- a/Emne 3/Pokemon/Program.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using Pokedex; -namespace Pokemon -{ - // 1/3 Planning - // 1/6 Coding - // 1/4 component test and early system test - // 1/4 system test, all components in hand - // - "The Mythical Man Month" by Frederick P. Brooks - class Program - { - static void Main(string[] args) - { - var pikachu = new Pikachu(); - Console.WriteLine($"Pikachu har {Pikachu.Health}hp og er level {Pikachu.Level}"); - } - } -} - diff --git a/Emne 3/Pokemon/pokemon.cs b/Emne 3/Pokemon/pokemon.cs deleted file mode 100644 index d6de17a..0000000 --- a/Emne 3/Pokemon/pokemon.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Pokedex; - - public class Pikachu -{ - internal static int Health = 50; - internal static int Level = 21; -} \ No newline at end of file