Skip to content

Commit

Permalink
Merge pull request #7456 from devcherry1/patch-13
Browse files Browse the repository at this point in the history
#8 - C#
  • Loading branch information
Roswell468 authored Dec 22, 2024
2 parents d1314b8 + 059aed7 commit 04b9293
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Roadmap/08 - CLASES/c#/devcherry1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
class Program
{
static void Main()
{
Videogame videogame1 = new Videogame("Lies Of Pi", 2023, "Souls");
Videogame videogame2 = new Videogame("Sekiro", 2019, "Souls");
Videogame.Conteo();
}
}
class Videogame
{
public string Nombre { get; set; }
public int Lanzamiento { get; set; }
public string Genero { get; set; }
public static int Total = 0;
/*Dado que el campo Total debe mantener un conteo compartido
* entre todas las instancias de la clase Videogame,
* este debe ser un miembro estático. De lo contrario,
* cada instancia tendrá su propio Total y el conteo no funcionará correctamente.
*/

public Videogame (string nombre, int lanzamiento, string genero)
{
Nombre = nombre;
Lanzamiento = lanzamiento;
Genero = genero;
Total += 1;
}
public static void Conteo()
{
Console.WriteLine($"Tienes {Total} videojuegos en la bibilioteca");
}
}

0 comments on commit 04b9293

Please sign in to comment.