public static void Main ()
SplashKit . OpenWindow ( " Light Switch " , 300 , 300 );
SplashKit . DownloadBitmap ( " On " , " https://programmers.guide/resources/code-examples/part-3/2-abstraction/medium-on-light.png " , 443 );
SplashKit . DownloadBitmap ( " Off " , " https://programmers.guide/resources/code-examples/part-3/2-abstraction/medium-off-light.png " , 443 );
Light light = new Light( 20 , 20 );
while ( ! SplashKit . QuitRequested ())
SplashKit . ProcessEvents ();
if ( SplashKit . MouseClicked ( MouseButton . LeftButton ) && light . IsUnderMouse )
SplashKit . ClearScreen ( Color . White );
SplashKit . ClearScreen ( Color . Black );
Console . WriteLine ( $" Light is on: { light . IsOn } " );
SplashKit . RefreshScreen ();
public Light ( double x, double y)
public void TogglePower ()
private string BitmapName
get { return _isOn ? " On " : " Off " ; }
get { return SplashKit . BitmapNamed (BitmapName); }
public double X { get ; set ; }
public double Y { get ; set ; }
get { return Image . PointCollision (X, Y, SplashKit . MouseX (), SplashKit . MouseY ()); }