How can I make my countdown timer loop in C# using virtual studio? -
i reading book on c#
in spare time (very new programming
, pardon inexperience) , have made far making timer
afking on game play. cant figure out how make countdown timer reset without having re run program manually. suggestions appreciated! thank much.
(first time poster)
public class afktimer { public void startprogram() { snapsengine.settitlestring("afk timer"); snapsengine.delay(3.0); snapsengine.speakstring("twenty minutes remaining"); snapsengine.delay(600.0); snapsengine.speakstring("ten minutes remaining"); snapsengine.delay(300.0); snapsengine.speakstring("five minutes remaining"); snapsengine.delay(240.0); snapsengine.speakstring("one minute remaining"); snapsengine.delay(60.0); snapsengine.speakstring("timer resetting"); } }
you can pass delay input parameter function. example:
using system.collections.generic; using system.linq; namespace test { public class program { private static void main(string[] args) { var delays = new list<int> { 600, 300, 240, 60 }; // list delays. delays.foreach(delay => startprogram(delay)); // each element in delays call startprogram. } public static void startprogram(int delay) { snapsengine.speakstring("{0} minutes remaining", delay / 60); snapsengine.delay(delay); } } }
the list contains information different delays. each element of list passed method startprogram
input parameter. method print string , wait amount of time.
Comments
Post a Comment