n/a
Dependencies: Circle Rectangle Shape Square mbed
main.cpp
- Committer:
- kch78
- Date:
- 2016-03-22
- Revision:
- 1:83e4a7cb4516
- Parent:
- 0:2f3ce9b79d39
File content as of revision 1:83e4a7cb4516:
#include "Shape.h" #include "Circle.h" #include "Rectangle.h" #include "Square.h" #include "mbed.h" #include <string> extern Serial pc(USBTX, USBRX); DigitalOut led(LED1); DigitalIn pb(USER_BUTTON); DigitalIn pb2(PC_8); int count = 0; int counter() { return ++count; } int counter2() { static int count2 = 0; return ++count2; pc.printf("\n\r Count2 : %d", count2); } int main() { pc.format(8,SerialBase::None,1); pc.baud(115200); pb.mode(PullUp); bool off = 0; pc.printf("\n\r START\n\r"); // napisz------------------ int licznikGuzika = 0; //int licznikGuzika2 = 0; struct fish { const char *name; const char *species; int teeth; int age; }; //-----------------------PETLA----------------------------------------------------- while(1) { static int licznikGuzika2 = 0; struct fish snappy = {"Snappy", "Piranha", 69, 4}; if (pb == 0) { off = !off; if (off) { licznikGuzika++; licznikGuzika2++; led = !led; pc.printf("\n\r Nazwa : %s", snappy.name); counter(); pc.printf("\n\r Count : %d", count); counter2(); Shape * papers[5]; Circle michael(1.0); Rectangle andrew(2.0,4.0); Circle ann(10); Square tim(100); Rectangle jonathan(20.0,25.0); papers[0] = &michael; papers[1] = &andrew; papers[2] = &ann; papers[3] = &tim; papers[4] = &jonathan; for (int k=0; k<5; k++) { pc.printf("\n\rArea is %f", papers[k]->getArea()); } } if (!off) { licznikGuzika++; licznikGuzika2++; led = !led; pc.printf("\n\rNazwa : %s", snappy.species); counter(); pc.printf("\n\r Count : %d", count); counter2(); } while (pb == 0); } //-------------------------CHECK------------------------------------------ if (pb2 == 0) { } } }