-
Notifications
You must be signed in to change notification settings - Fork 0
/
Animal.cs
50 lines (46 loc) · 1.34 KB
/
Animal.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Lab_6___OOP_Arv
{
public abstract class Animal
{
// Egenskaper tilldelat med defaultvärde
public string name { get; set; } = "noName";
public int age { get; set; } = 0;
public string color { get; set; } = "Unknown";
public string birthplace { get; set; } = "Unknown";
public double weight { get; set; } = 0.0;
public Animal(string name, int age, string color, string birthplace, double weight)
{
this.name = name;
this.age = age;
this.color = color;
this.birthplace = birthplace;
this.weight = weight;
}
public void sleep(bool nosie)
{
if (nosie)
{
Console.WriteLine("Du väkte ditt djur");
}
else
{
Console.WriteLine("Zzz");
}
}
public virtual void makeSound()
{
Console.WriteLine(" OoooooOOoooOOoo ");
}
public virtual void ShowInfo()
{
Console.WriteLine($"Name: {name} + Age: {age} Color: {color} Birthplace: {birthplace} Weight {weight}");
}
}
}