File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ class Program
3
+ {
4
+ static void Main ( )
5
+ {
6
+ Videogame videogame1 = new Videogame ( "Lies Of Pi" , 2023 , "Souls" ) ;
7
+ Videogame videogame2 = new Videogame ( "Sekiro" , 2019 , "Souls" ) ;
8
+ Videogame . Conteo ( ) ;
9
+ }
10
+ }
11
+ class Videogame
12
+ {
13
+ public string Nombre { get ; set ; }
14
+ public int Lanzamiento { get ; set ; }
15
+ public string Genero { get ; set ; }
16
+ public static int Total = 0 ;
17
+ /*Dado que el campo Total debe mantener un conteo compartido
18
+ * entre todas las instancias de la clase Videogame,
19
+ * este debe ser un miembro estático. De lo contrario,
20
+ * cada instancia tendrá su propio Total y el conteo no funcionará correctamente.
21
+ */
22
+
23
+ public Videogame ( string nombre , int lanzamiento , string genero )
24
+ {
25
+ Nombre = nombre ;
26
+ Lanzamiento = lanzamiento ;
27
+ Genero = genero ;
28
+ Total += 1 ;
29
+ }
30
+ public static void Conteo ( )
31
+ {
32
+ Console . WriteLine ( $ "Tienes { Total } videojuegos en la bibilioteca") ;
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments