-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cs
145 lines (112 loc) · 3.51 KB
/
main.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// write a hello world example in c#
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
// Conference class
class Conference
{
public string Name { get; set; }
public string Location { get; set; }
public string Date { get; set; }
public Speakers<Speaker> Speakers { get; set; }
public Conference(string name, string location, string date)
{
Name = name;
Location = location;
Date = date;
}
public void PrintConferenceDetails()
{
Console.WriteLine("Conference Name: {0}", Name);
Console.WriteLine("Conference Location: {0}", Location);
Console.WriteLine("Conference Date: {0}", Date);
}
// Method to add a speaker to the conference
public void AddSpeaker(Speaker speaker)
{
// Add speaker to the list of speakers
Speakers.Add(speaker);
Console.WriteLine("Speaker {0} added to conference {1}", speaker.Name, Name);
}
// Method to remove a speaker from the conference
public void RemoveSpeaker(Speaker speaker)
{
// Remove speaker from the list of speakers
Speakers.Remove(speaker);
Console.WriteLine("Speaker {0} removed from conference {1}", speaker.Name, Name);
}
}
class Speaker
{
public string Name { get; set; }
public string Language { get; set; }
public sbyte Age { get; set; }
public int SpeakerID { get; set; }
public Speaker(string name, string language, sbyte age)
{
Name = name;
Language = language;
Age = age;
SpeakerID = GetSpeakerID();
}
private int GetSpeakerID(){
// Generate random speaker ID from 1 to 1000
Random random = new Random();
int _speakerID = random.Next(1, 1000);
return _speakerID;
}
public void Speak()
{
Console.WriteLine("Hello World!");
}
}
class Tests
{
// Generate a method to test the Conference class
public void TestConference()
{
// Create a new conference
Conference conference = new Conference("Tech Summit", "New York", "2021-10-10");
// Print conference details
conference.PrintConferenceDetails();
// Create a new speaker
Speaker speaker = new Speaker("John Doe", "English", 30);
// Add speaker to the conference
conference.AddSpeaker(speaker);
// Remove speaker from the conference
conference.RemoveSpeaker(speaker);
}
}
class Speakers<T>
{
private List<T> _speakers = new List<T>();
public void Add(T speaker)
{
_speakers.Add(speaker);
}
public void Remove(T speaker)
{
_speakers.Remove(speaker);
}
}
// Main method
class MainClass
{
static void Main(string[] args)
{
// Create a new instance of the Tests class
Tests tests = new Tests();
// Run the TestConference method
tests.TestConference();
// Create a new instance of the Speaker class
Speaker speaker = new Speaker("John Doe", "English", 30);
}
}
}