-
Notifications
You must be signed in to change notification settings - Fork 0
/
ai.rumordef.cs
36 lines (29 loc) · 1.35 KB
/
ai.rumordef.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
// Sure, here's a simple C# program that defines a `Rumor` class and populates a list of rumors from user input:
// ```csharp
using System;
using System.Collections.Generic;
public class Rumor
{
public string Content { get; set; }
}
class Program
{
static void Main(string[] args)
{
List<Rumor> rumors = new List<Rumor>();
for (int i = 0; i < 5; i++)
{
Console.Write("Enter rumor " + (i + 1) + ": ");
string rumorContent = Console.ReadLine();
Rumor rumor = new Rumor { Content = rumorContent };
rumors.Add(rumor);
}
Console.WriteLine("\nYou've entered the following rumors:");
foreach (Rumor rumor in rumors)
{
Console.WriteLine("- " + rumor.Content);
}
}
}
```
// This program will prompt the user to enter the content of up to 5 rumors. Each rumor is stored as an instance of the `Rumor` class, which is then added to a list of rumors. After all rumors have been entered, the program will output the content of each rumor. Please note that this program does not validate the input. If the user enters nothing and just presses enter, an empty rumor will be added to the list. Also, the program does not check for duplicate rumors. If the user enters the same rumor more than once, it will be added to the list each time it is entered.