Codeschnippseln für diese Übung

Dependencies:   mbed

class4.cpp

Committer:
Aagrus
Date:
2020-10-13
Revision:
2:7a0bae2281e8
Parent:
1:c65875995efb

File content as of revision 2:7a0bae2281e8:

#include "mbed.h"


class MyPrintClass
{
    private:
        Serial* pc;
        
    public:
        MyPrintClass(Serial* serial) : pc(serial)
        {
            
        }
        
        
        void PrintIntValues(int value)
        {
            pc->printf("Int-Wert: %d\n", value);
        }
        void PrintIntValues(int *values, int count)
        {
            pc->printf("Auflistung der %d Messwerte:\n", count);
            
            for (int i = 0; i < count; i++)
            {
                pc->printf("[%d] -> %d\n", i, values[i]);
            }
            
            pc->printf("Auflistung beendet!\n\n");
        }
        
        void PrintString(char *str)
        {
            pc->printf("String: ");
            int i = 0;
            
            while(true)
            {
                if (str[i] == '\0')
                    break;
                    
                pc->putc(str[i]);
                i++;
            }
            
            pc->printf("\n");
        }
        
};