In the code below, I can't figure out how to use the objects Italy and France with their timers. The code works, but if I create a local object of them, it won't keep the data. Or if I try to create a global object, I end up getting ambiguity errors ( even when I'm just assigning them an instance! ). Please help me, as I am very frustrated with not being able to get it to actually use the same instance of a object in the timers.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public int interval = 1;
void DeclareObjects();
public Form1()
{
InitializeComponent();
StartTimers.Enabled = true;
StartTimers.Start();
}
private void StartTimers_Tick(object sender, EventArgs e)
{
switch (interval)
{
case 1: GiveTroopsToItaly.Enabled = true; GiveTroopsToItaly.Start(); break;
case 2: GiveTroopsToFrance.Enabled = true; GiveTroopsToFrance.Start(); break;
}
if (interval == 2)
{
StartTimers.Enabled = false;
StartTimers.Stop();
return;
}
else
{
interval++;
}
}
private void GiveTroopsToItaly_Tick(object sender, EventArgs e)
{
}
private void GiveTroopsToFrance_Tick(object sender, EventArgs e)
{
}
private void DeclareObjects()
{
Country Italy;
Country France;
Italy = new Country(ItalyTroopCount, 0);
France = new Country(FranceTroopCount, 0);
}
}
}