Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace HospitalPatients
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- List<string> patients = Console.ReadLine() //"Ivan, Peter, Simona, Krasimir, Petya".split(", ")
- .Split(", ") //["Ivan", "Peter", "Simona", "Krsimir", "Petya"]
- .ToList(); // {"Ivan", "Peter", "Simona", "Krsimir", "Petya"}
- string command = Console.ReadLine(); //"END OF PATIENTS" или команда
- //повтаряме: въвеждаме нова команда
- //стоп: команда == "END"
- //продължаваме: команда != "END"
- while (command != "END OF PATIENTS")
- {
- //валидна команда -> проверка коя е командата
- if (command == "Add patient")
- {
- string name = Console.ReadLine(); //име на пациент за добавяне
- patients.Add(name);
- }
- else if (command == "Add patient on position")
- {
- string name = Console.ReadLine(); //име на пациент за добавяне
- int position = int.Parse(Console.ReadLine()); // позиция на добавяне
- patients.Insert(position, name);
- }
- else if (command == "Remove patient on position")
- {
- int position = int.Parse(Console.ReadLine());
- patients.RemoveAt(position);
- }
- else if (command == "Remove last patient")
- {
- patients.RemoveAt(patients.Count - 1);
- }
- else if (command == "Remove first patient")
- {
- patients.RemoveAt(0);
- }
- command = Console.ReadLine();
- }
- Console.WriteLine(string.Join(" ", patients));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement