Essays.club - Получите бесплатные рефераты, курсовые работы и научные статьи
Поиск

Модель работы телевизора, состоящую из 3-4 свойства

Автор:   •  Сентябрь 18, 2019  •  Лабораторная работа  •  638 Слов (3 Страниц)  •  400 Просмотры

Страница 1 из 3

Савин Владимир, Шапи Гаджикурбанов ИКТ-615

Отчёт по лабораторной работе №3

  1. Постановка задачи: разработать модель работы телевизора, состоящую из 3-4 свойства, наиболее существенных для описания поведения устройства, и 3-6 методов, моделирующих поведение телевизора.
  2. UML-диаграмма компонентов














    [pic 1][pic 2][pic 3][pic 4][pic 5][pic 6][pic 7][pic 8][pic 9]
  3. Текст программы:


newClass.h:

/*

 * File:   tv.h

 * Author: idgman

 *

 * Created on 6 Oct 2017, 19:39

 */

#ifndef TV_H

#define        TV_H

class TV

{

  public:

      TV();

      ~TV();

      void on_off();

      void switch_channel();

      void switch_channel(int);

      void contrast_plus();

      void contrast_minus();

      void show();

private:

      int is_on;

      int picture;

      int channel;

      int light;

};

#endif


newClass.cpp:

#include

#include "tv.h"

using namespace std;

TV::TV(): is_on(0), picture(0), channel(1), light(1)

{

}

TV::~TV()

{

}

void TV::on_off()

{

    is_on=!is_on;

    picture=!picture;

}

void TV::switch_channel()

{

    if (is_on) channel++;

    if(channel>5) channel=1;

}

void TV::switch_channel(int p)

{

    if (is_on&&p>0&&p<6) channel=p;

}

void TV::contrast_plus()

{

    if(is_on&&light<3) light++;

}

void TV::contrast_minus()

{

    if(is_on&&light>0) light--;

}

void TV::show()

{

     if (is_on) cout<<"\nPOWER On"<

     else cout<<"\nPOWER Off"<

     if (picture&&light>0) cout<<"PICTURE On"<

     else cout<<"PICTURE Off"<

     cout<<"CHANNEL: "<

     cout<<"BRIGHTNESS: "<

}


main.cpp:

/*

 * File:   main.cpp

 * Author: idgman

 *

 * Created on 6 Oct 2017, 19:39

 */

#include

#include

#include "tv.h"

using namespace std;

int main(int argc, char** argv)

{

    TV tv;

    int command, end=1;

    tv.show();

    while(end)

    {

        //ВЫВОД МЕНЮ КОМАНД

        cout<<"\nList of commands:\n";

        cout<<"1. Power management\n";

        cout<<"2. Channels switching in order\n";

...

Скачать:   txt (4.1 Kb)   pdf (126.9 Kb)   docx (13.7 Kb)  
Продолжить читать еще 2 страниц(ы) »
Доступно только на Essays.club