-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
58 lines (54 loc) · 1.98 KB
/
Program.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
51
52
53
54
55
56
57
58
using System;
namespace Dog_Challenge
{
public enum Gender{
Male,
Female,
}
class Dog{
public string name;
public string owner;
public int age;
public Gender gender;
public Dog(string DName,string OName,int Age,Gender genda){
name=DName;
owner=OName;
age=Age;
gender= genda;
}
public void Bark(int barks){
for(;barks>0;barks--){
Console.WriteLine("Woof!");
}
}
public string GetTag(){
string str;
str=$"If lost call {owner}.";
if((int)gender==0){
str=str+$" His name is {name} and he is {age}";
}
else{
str=str+$" Her name is {name} and she is {age}";
}
if(age==1){
str=str+ " year old.";
}
else{
str=str+" years old.";
}
return(str);
}
}
class Program
{
static void Main(string[] args)
{
Dog puppy = new Dog("Orion", "Shawn", 1, Gender.Male); // create object instance
puppy.Bark(5); // output: Woof!Woof!Woof!
Console.WriteLine(puppy.GetTag()); // output: If lost, call Shawn. His name is Orion and he is 1 year old.
Dog myDog = new Dog("Lileu", "Dale", 4, Gender.Female); // create object instance
myDog.Bark(1); // output: Woof!
Console.WriteLine(myDog.GetTag()); // output: If lost, call Dale. Her name is Lileu and she is 4 years old.
}
}
}