Första uppladdningen av övningsexempel
This commit is contained in:
commit
eb307ea123
88 files changed
+1293
No files matched your search
@@ -0,0 +1,28 @@
|
||||
// Skapa en klass som heter Bok. Klassen ska ha egenskaper för titel, författare, antal sidor och om boken är utlånad. Lägg även till en konstruktor och en metod som skriver ut information om boken.
|
||||
|
||||
Bok bok = new Bok("1984", "George Orwell", 328, false);
|
||||
bok.SkrivInformation();
|
||||
|
||||
class Bok
|
||||
{
|
||||
public string Titel { get; set; }
|
||||
public string Forfattare { get; set; }
|
||||
public int AntalSidor { get; set; }
|
||||
public bool ArUtlanad { get; set; }
|
||||
|
||||
public Bok(string titel, string forfattare, int antalSidor, bool arUtlanad)
|
||||
{
|
||||
Titel = titel;
|
||||
Forfattare = forfattare;
|
||||
AntalSidor = antalSidor;
|
||||
ArUtlanad = arUtlanad;
|
||||
}
|
||||
|
||||
public void SkrivInformation()
|
||||
{
|
||||
Console.WriteLine($"Titel: {Titel}");
|
||||
Console.WriteLine($"Författare: {Forfattare}");
|
||||
Console.WriteLine($"Antal sidor: {AntalSidor}");
|
||||
Console.WriteLine($"Utlånad: {ArUtlanad}");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user