Jump to content

Programing question (using processing)?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
dirtyoldman812

dirtyoldman812

    Newbie

  • Members
  • Pip
  • 1 posts
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

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What language? This should be pretty easy.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Ancient Dragon

Ancient Dragon

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 400 posts
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
Ancient Dragon

Ancient Dragon

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 400 posts
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.