using System; using System.Windows.Forms; using System.Drawing; public class WaterSystemApp : Form { private FlowLayoutPanel _panel; private Button _button; private WaterTank _tank; public WaterSystemApp(){ this.InitializeComponents(); } public void InitializeComponents(){ _tank = new WaterTank(); _button = new Button(); _button.Text = "Add Water"; _button.Click += new EventHandler(this.AddWaterButtonClick); _button.Dock = DockStyle.Bottom; _panel = new FlowLayoutPanel(); _panel.SuspendLayout(); _panel.FlowDirection = FlowDirection.TopDown; _panel.AutoSize = true; _panel.AutoSizeMode = AutoSizeMode.GrowAndShrink; _panel.Height = _tank.Height + _button.Height + 75; _panel.Controls.Add(_tank); _panel.Controls.Add(_button); this.SuspendLayout(); this.Text = "Water System"; this.Height = _panel.Height; this.Width = _tank.Width; this.Controls.Add(_panel); _panel.ResumeLayout(); this.ResumeLayout(); } public void AddWaterButtonClick(object sender, EventArgs e){ _tank.ChangeWaterLevel(_tank.FillRate); } public static void Main(){ Application.Run(new WaterSystemApp()); } }