I have to make a program that do this
"Write a Processing program that simulates a “clicker” to count attendance. Your
program should display a sequence of digits (initially all 0s) in the center of the
window. Two marked areas inside the window represent “count” and “reset” buttons.
When the user clicks on the “count” button, the numeric counter should increase by 1.
When the user clicks on the “reset” button, the counter should reset itself to 0. Your
counter must have at least 4 digits; when the counter reaches all 9s, clicking on the
“count” button should cause it to roll over to all 0s and begin counting up from 1
again. You can use the text display functions from Chapter 17 to do this, or you can
display your counter using image files. "
What i have is, to display the 4 digits, and the count button, and reset button on the screen. But i don't know how to make the count button increase 1 each time its clicked. and also the reset button. Currently using "String" to display the 4 digits. and "text" for the buttons.
any help would be great. Thanks
Programing question (using processing)?
Started by dirtyoldman812, May 04 2010 11:22 AM
3 replies to this topic
#1
Posted 04 May 2010 - 11:22 AM
|
|
|
#2
Posted 04 May 2010 - 04:51 PM
What language? This should be pretty easy.
#3
Posted 04 May 2010 - 05:32 PM
If you are using C++ Forms or VB just set event handlers for the buttons. If you don't know how to do that then you need to read/view walk throughs for the language of choice because they will teach you how to do it.
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.
#4
Posted 04 May 2010 - 06:18 PM
One way to format the strings is to use std::stringstream and std::string class, then convert it to System::String class. In the code snippet below the variable counter is just an int which is a member of the Form classl.
#include <string>
#incluide <sstream>
#include <iomanip>
<snip>
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
++counter;
if(counter > 9999)
counter = 0;
std::stringstream str;
str << std::setw(4) << std::setfill('0') << counter;
std::string n = str.str();
String ^someString= gcnew String(n.c_str());
this->label1->Text = someString;
}
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.


Sign In
Create Account

Back to top









