110k views
5 votes
How would you change the PushCounterPanel class so that instead of displaying a count of how many times the button was pushed, it displays a count "trail"?

a.After one push, it displays "01";
b.after two pushes, it displays "012";
c.after five pushes, it displays "012345"; and so on.

User Bob Ralian
by
8.6k points

1 Answer

2 votes

Answer:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace WindowsFormsApp1

{

public partial class Form1 : Form

{

int count = 0;

string countInfo = "0" ;

string info = "";

string newline = Environment.NewLine;

public Form1()

{

InitializeComponent();

label1.Text = count.ToString();

}

private void button1_Click(object sender, EventArgs e)

{

//push counter

count += 1;

//add the new push to the previous count

countInfo = countInfo + count.ToString();

//add the new puch trail to all trails with newline

info = info + countInfo + newline ;

label1.Text = info;

}

}

}

Step-by-step explanation:

Application designed using Desktop App for c#.

How would you change the PushCounterPanel class so that instead of displaying a count-example-1
User James W Simms
by
7.4k points