Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- public class Server
- {
- private static string name;
- public Server()
- {
- }
- public Server(string x)
- {
- name = x;
- }
- static string ans = "";
- public static Server Connect(string Name)
- {
- if (name is null) return new Server(Name);
- else return new Server(name);
- }
- public void Send(string message)
- {
- if(name is null)
- {
- throw new ArgumentException("No connected server");
- }
- ans += $"Sending data {message} to server {name }";
- ans += Environment.NewLine;
- }
- public void Receive(string message)
- {
- if (name is null)
- {
- throw new ArgumentException("No connected server");
- }
- ans += $"Receiving data {message} from server {name}";
- ans += Environment.NewLine;
- }
- public void Output()
- {
- if (name is null)
- {
- throw new ArgumentException("No connected server");
- }
- Console.Write(ans);
- ans = "";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement