35 lines
727 B
C#
35 lines
727 B
C#
|
|
using System;
|
||
|
|
|
||
|
|
namespace Lesson06.Devices
|
||
|
|
{
|
||
|
|
class Microphone : IDevice
|
||
|
|
{
|
||
|
|
private string name;
|
||
|
|
public bool IsConnected { get; private set; }
|
||
|
|
|
||
|
|
public Microphone(string name)
|
||
|
|
{
|
||
|
|
this.name = name;
|
||
|
|
this.IsConnected = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Connect()
|
||
|
|
{
|
||
|
|
if (!IsConnected)
|
||
|
|
{
|
||
|
|
IsConnected = true;
|
||
|
|
Console.WriteLine($"[{name}] 麦克风已连接");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Disconnect()
|
||
|
|
{
|
||
|
|
if (IsConnected)
|
||
|
|
{
|
||
|
|
IsConnected = false;
|
||
|
|
Console.WriteLine($"[{name}] 麦克风已断开");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|