first events

This commit is contained in:
test
2019-04-09 16:14:26 +02:00
parent 5cfbf8d0a5
commit b8f984edd9
13 changed files with 229 additions and 23 deletions

View File

@ -1,29 +1,122 @@
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using VCRlogic;
public class SMtape
namespace VCRlogic
{
private SMtape _concreteState;
public SMtape()
public static class SMtape
{
private static StateTape _concreteState;
public delegate void TapeEventHandler();
public static event TapeEventHandler evIntape;
public static event TapeEventHandler evOuttape;
public static void initSMtape()
{
setState(new StapeNoTapeIn());
//evIntape += evIntape;
}
public static void setState(StateTape e)
{
_concreteState = null;
_concreteState = e;
}
public static void insertTape()
{
if (evIntape != null)
{
evIntape();
}
}
public static void ejectTape()
{
if (evOuttape != null)
{
evOuttape();
}
}
}
}
public class SMtapeNoTapeIn : SMtape
public abstract class StateTape
{
public abstract void evIntape();
public abstract void evOuttape();
}
public class SMtapeTapeInNotEnd : SMtape
public class StapeNoTapeIn : StateTape
{
public override void evIntape()
{
Debug.Print("tape is now in\n");
//unsub
SMtape.evIntape -= evIntape;
SMtape.setState(new StapeTapeInNotEnd());
}
public override void evOuttape()
{
}
public StapeNoTapeIn()
{
// sub to event
SMtape.evIntape += evIntape;
}
}
public class SMtapeTapeInEnd : SMtape
public class StapeTapeInNotEnd : StateTape
{
}
public override void evIntape()
{
}
public override void evOuttape()
{
Debug.Print("tape is now out\n");
//unsub
SMtape.evOuttape -= evOuttape;
SMtape.setState(new StapeNoTapeIn());
}
public StapeTapeInNotEnd()
{
//sub
SMtape.evOuttape += evOuttape;
}
}
/*
public class StapeTapeInEnd : StateTape
{
public override void setStateText()
{
throw new NotImplementedException();
}
}
*/

View File

@ -9,7 +9,17 @@ public class SMvcr
{
private string _labelText;
private SMvcr _concreteState;
private StateVCR _concreteState;
public SMvcr()
{
setState(new SvcrStandBy());
}
public void setState(StateVCR e)
{
_concreteState = e;
}
public string getLabelText()
{
@ -18,25 +28,50 @@ public class SMvcr
}
public class SMvcrStandBy : SMvcr
public abstract class StateVCR
{
public abstract void setStateText();
}
public class SvcrStandBy : StateVCR
{
public override void setStateText()
{
throw new NotImplementedException();
}
}
public class SMvcrPlay : SMvcr
public class SvcrPlay : StateVCR
{
public override void setStateText()
{
throw new NotImplementedException();
}
}
public class SMvcrRewind : SMvcr
public class SvcrRewind : StateVCR
{
public override void setStateText()
{
throw new NotImplementedException();
}
}
public class SMvcrFastForward : SMvcr
public class SvcrFastForward : StateVCR
{
public override void setStateText()
{
throw new NotImplementedException();
}
}
public class SMvcrRecord : SMvcr
public class SvcrRecord : StateVCR
{
public override void setStateText()
{
throw new NotImplementedException();
}
}