Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class Czas {
- private:
- int sekundy;
- int minuty;
- int godziny;
- public:
- int podajSekundy();
- int podajMinuty();
- int podajGodziny();
- void ustawSek(int _ile);
- void ustawMin(int _ile);
- void ustawGodz(int _ile);
- void podajStan();
- };
- #include "Czas.h"
- int Czas::podajSekundy()
- {
- return sekundy;
- }
- int Czas::podajMinuty()
- {
- return minuty;
- }
- int Czas::podajGodziny()
- {
- return godziny;
- }
- void Czas::ustawSek(int _ile)
- {
- if (_ile >= 0 && _ile < 60) {
- sekundy = _ile;
- }
- else {
- sekundy = 0;
- std::cout << "ERROR - niepoprawny format czasu";
- }
- }
- void Czas::ustawMin(int _ile)
- {
- if (_ile >= 0 && _ile < 60) {
- minuty = _ile;
- }
- else {
- minuty = 0;
- std::cout << "ERROR - niepoprawny format czasu";
- }
- }
- void Czas::ustawGodz(int _ile)
- {
- if (_ile >= 0 && _ile < 60) {
- godziny = _ile;
- }
- else {
- godziny = 0;
- std::cout << "ERROR - niepoprawny format czasu";
- }
- }
- void Czas::podajStan() {
- std::cout << "Sekundy:"<< " " << sekundy<<" " << "Minuty:"<< " " << minuty<< " " << "Godziny:" << " " << godziny<< " " << std::endl;
- }
- #include "Czas.h"
- #include <iostream>
- int main()
- {
- Czas Test1, Test2, Test3;
- Test1.ustawSek(3);
- Test1.ustawMin(50);
- Test1.ustawGodz(23);
- Test1.podajStan();
- Test2.ustawSek(45);
- Test2.ustawMin(2);
- Test2.ustawGodz(11);
- Test2.podajStan();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement