Projektdateien hinzufügen.
This commit is contained in:
31
BeispielStatic/Program.cs
Normal file
31
BeispielStatic/Program.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
namespace BeispielStatic
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Auto a1 = new Auto("Fiat", "500");
|
||||
Auto a2 = new Auto("Ford", "Fiesta");
|
||||
int anzahl = Auto.GetAnzahl();
|
||||
Console.WriteLine(anzahl);
|
||||
|
||||
Console.WriteLine(a1.GetAnzahl2());
|
||||
Console.WriteLine(a2.GetAnzahl2());
|
||||
}
|
||||
class Auto
|
||||
{
|
||||
private string marke;
|
||||
private string modell;
|
||||
|
||||
private static int anzahl;
|
||||
public Auto(string marke, string modell)
|
||||
{
|
||||
this.marke = marke;
|
||||
this.modell = modell;
|
||||
anzahl = anzahl + 1;
|
||||
}
|
||||
public static int GetAnzahl() { return anzahl; }
|
||||
public int GetAnzahl2() { return anzahl; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user