Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
рпз.docx
Скачиваний:
76
Добавлен:
08.03.2016
Размер:
243.23 Кб
Скачать
  1. Основание для разработки.

Основанием для разработки является задание на курсовую работу по дисциплине «Объектно-ориентированное программирование» по теме «Объектно-ориентированное программирование на языке C++».

Задание:

  1. Разработайте иерархию родственных типов для моделирования и обработки данных предметной области согласно варианта А.х.х.

  2. Реализуйте функции обработки данных (сортировка и поиск по выбранным полям и задаваемым диапазонам значений, другие функции, в том числе перегруженные).

  3. Реализуйте файловый ввод/вывод и ввод данных с клавиатуры, вывод данных на дисплей.

  4. Предусмотрите обработку различных исключительных ситуаций.

  5. Работа всех функций должна быть проверена и результаты проверки оформлены протоколом тестирования.

  1. Назначение.

Основным назначением программного продукта является осуществление работы с данными о бытовой технике.

  1. Требования к классам.

4.1. Требования к функциональным характеристикам.

Классы должны включать в себя:

  1. Иерархию родственных типов, для моделирования предметной области «Бытовая техника.

  2. Реализацию файлового ввода/вывода и вывод данных на дисплей. Файловый ввод-вывод позволяет считывать данные из множества различных файлов, и выводить их в другие (или те же) файлы; для каждого класса создается свой файл, в который построчно записываются данные объектов этого класса.

  3. Реализацию функции обработки данных (поиск по полю).

4.3. Требования к составу и параметрам технических средств.

Система предназначена для работы на IBM-совместимых персональных компьютерах с ОС Windows 98/ME/2000/XP/Vista/7/8.

Минимальная конфигурация:

  • тип процессора PentiumIII / PentiumIV;

  • объем оперативного запоминающего устройства 16 Мб и более;

  • объем свободного места на жестком диске 5 Мб.

Для работы требуются внешние устройства – монитор, клавиатура, мышь.

4.4. Требования к информационной и программной совместимости.

Классы будут разработаны на языке C++ в среде Visual Studio 13 и должна работать под управлением операционной системы семейства Windows (Windows 98/ME/2000/XP/Vista/7/8). Дополнительного программного обеспечения для функционирования не требуется.

5. Требования к программной документации.

Программная документация будет содержать:

  • расчетно-пояснительную записку;

  • текст программы;

  • руководство пользователя.

6. Стадии и этапы разработки.

Таблица П1.1.

Этапы разработки

Этапы разработки

Плановая дата

Фактическая дата

Объектно-ориентированный анализ предметной области

20 мая

20 мая

Проектирование необходимых динамических структур

20 мая

20 мая

Разработка и реализация алгоритмов

20 мая

20 мая

Отладка и тестирование

20 мая

20 мая

Составление программной документации

20 мая

20 мая

7. Порядок контроля и приемки.

Основная процедура контроля и приема работы будет происходить путем защиты курсовой работы.

Приложение 2.

Текст программы

Класс tehnika.

#pragma once

#include <string>

#include <sstream>

#include <clocale>

#include <iostream>

class tehnika

{

public:

std::string firma;

std::string model;

int cena;

tehnika(std::string firma, std::string model, int cena)

{

this->firma = firma;

this->model = model;

this->cena = cena;

};

void tehniki()

{

firma = "";

model = "";

cena = 0;

};

void tehniki(std::string f, std::string m, int c)

{

firma = f;

model = m;

cena = c;

};

void print_teh()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Фирма производителя: " << firma << std::endl;

std::cout << "Модель устройства: " << model << std::endl;

std::cout << "Цена: " << cena << " руб " << std::endl;

system("pause");

}

;

};

Класс AUDIO_VIDEO.

#include <iostream>

#include <string>

#include <sstream>

#include <cstdlib>

#include "tehnika.h"

#include <clocale>

class AUDIO_VIDEO : public tehnika

{

public:

std::string klass_potr_en;

std::string format;

std::string energopot;

AUDIO_VIDEO(

std::string firma,

std::string model,

int cena,

std::string klass_potr_en,

std::string format,

std::string energopot

) : tehnika(

firma,

model,

cena

) {

this->klass_potr_en = klass_potr_en;

this->format = format;

this->energopot = energopot;

}

void AVi()

{

firma = "";

model = "";

cena = 0;

klass_potr_en = "";

format = "";

energopot = "";

};

void AVi(std::string f, std::string m, int c, std::string kpe, std::string fo, std::string e)

{

firma = f;

model = m;

cena = c;

klass_potr_en = kpe;

format = fo;

energopot = e;

};

void print_AV()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Класс потребления электроенергии: " << klass_potr_en << std::endl;

std::cout << "Формат: " << format << std::endl;

std::cout << "Энергопотребление: " << energopot << std::endl;

system("pause");

};

};

Класс TV.

#include <iostream>

#include <string>

#include <sstream>

#include <cstdlib>

#include "AUDIO_VIDEO.h"

#include <clocale>

#include <fstream>

class TV : public AUDIO_VIDEO

{

public:

float diagonal;

bool triD;

std::string tip_tv;

TV(

std::string firma,

std::string model,

int cena,

std::string klass_potr_en,

std::string format,

std::string energopot,

float diagonal,

bool triD,

std::string tip_tv

) : AUDIO_VIDEO(

firma,

model,

cena,

klass_potr_en,

format,

energopot)

{

this->diagonal = diagonal;

this->triD = triD;

this->tip_tv = tip_tv;

}

void TVi()

{

firma = "";

model = "";

cena = 0;

klass_potr_en = "";

format = "";

energopot = "";

diagonal = 0;

triD = false;

tip_tv = "";

};

void TVi(std::string f, std::string m, int c, std::string kpe, std::string fo, std::string e, float d, bool td, std::string tt)

{

firma = f;

model = m;

cena = c;

klass_potr_en = kpe;

format = fo;

energopot = e;

diagonal = d;

triD = td;

tip_tv = tt;

};

void print_TV()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Диагональ: " << diagonal << std::endl;

std::cout << "3D: " << triD << std::endl;

std::cout << "Тип: " << tip_tv << std::endl;

system("pause");

};

void print_TVall()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Фирма производителя: " << firma << std::endl;

std::cout << "Модель: " << model << std::endl;

std::cout << "Цена: " << cena << std::endl;

std::cout << "Класс потребления энергии: " << klass_potr_en << std::endl;

std::cout << "Формат: " << format << std::endl;

std::cout << "Энергопотребление: " << energopot << std::endl;

std::cout << "Диагональ: " << diagonal << std::endl;

std::cout << "3D: " << triD << std::endl;

std::cout << "Тип: " << tip_tv << std::endl;

system("pause");

};

void TVs()

{

setlocale(LC_CTYPE, "rus");

ofstream fout("TV.txt", ios_base::app);

fout << firma << " " << model << " " << cena << " " << klass_potr_en << " " << format << " " << energopot << " " << diagonal << " " << triD << " " << tip_tv;

fout.close();

system("pause");

};

void TVo()

{

setlocale(LC_CTYPE, "rus");

char buff[50];

ifstream fin("TV.txt");

while (!fin.eof())

{

fin >> buff;

cout << buff << endl;

}

fin.close();

system("pause");

};

void TVp(char slovo[1024])

{

ifstream fin("TV.txt");

char buffer[1024];

while (!fin.eof)

{

fin.getline(buffer, 1024);

if (strstr(buffer, slovo))

cout << buffer << endl;

};

system("pause");

};

};

Класс Proigr.

#include <iostream>

#include <string>

#include <sstream>

#include <cstdlib>

#include "AUDIO_VIDEO.h"

#include <clocale>

#include <fstream>

using namespace std;

class Proigr : public AUDIO_VIDEO

{

public:

std::string tip_n;

std::string tip_pr;

std::string portat;

Proigr(

std::string firma,

std::string model,

int cena,

std::string klass_potr_en,

std::string format,

std::string energopot,

std::string tip_n,

std::string tip_pr,

std::string portat

) : AUDIO_VIDEO(

firma,

model,

cena,

klass_potr_en,

format,

energopot)

{

this->tip_n = tip_n;

this->tip_pr = tip_pr;

this->portat = portat;

}

void proigri()

{

firma = "";

model = "";

cena = 0;

klass_potr_en = "";

format = "";

energopot = "";

tip_n = "";

tip_pr = "";

portat = "";

};

void proigri(std::string f, std::string m, int c, std::string kpe, std::string fo, std::string e, std::string tn, std::string tp, std::string p)

{

firma = f;

model = m;

cena = c;

klass_potr_en = kpe;

format = fo;

energopot = e;

tip_n = tn;

tip_pr = tp;

portat = p;

};

void print_Pro()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Тип носителя: " << tip_n << std::endl;

std::cout << "Тип проигрывателя: " << tip_pr << std::endl;

std::cout << "Портативный: " << portat << std::endl;

system("pause");

};

void print_Proall()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Фирма производителя: " << firma << std::endl;

std::cout << "Модель: " << model << std::endl;

std::cout << "Цена: " << cena << std::endl;

std::cout << "Класс потребления энергии: " << klass_potr_en << std::endl;

std::cout << "Формат: " << format << std::endl;

std::cout << "Энергопотребление: " << energopot << std::endl;

std::cout << "Тип носителя: " << tip_n << std::endl;

std::cout << "Тип проигрывателя: " << tip_pr << std::endl;

std::cout << "Портативный: " << portat << std::endl;

system("pause");

};

void proigrs()

{

setlocale(LC_CTYPE, "rus");

ofstream fout("proigr.txt", ios_base::app);

fout << firma << " " << model << " " << cena << " " << klass_potr_en << " " << format << " " << energopot << " " << tip_n << " " << tip_pr << " " << portat;

fout.close();

system("pause");

};

void proigro()

{

setlocale(LC_CTYPE, "rus");

char buff[50];

ifstream fin("proigr.txt");

while (!fin.eof())

{

fin >> buff;

cout << buff << endl;

}

fin.close();

system("pause");

};

void proigrp(char slovo[1024])

{

ifstream fin("proigr.txt");

char buffer[1024];

while (!fin.eof)

{

fin.getline(buffer, 1024);

if (strstr(buffer, slovo)) cout << buffer << endl;

};

system("pause");

};

};

Класс Telephon.

#include <iostream>

#include <string>

#include <sstream>

#include <cstdlib>

#include "tehnika.h"

#include <clocale>

class Telephon : public tehnika

{

public:

std::string batareya;

std::string vess;

Telephon(

std::string firma,

std::string model,

int cena,

std::string batareya,

std::string vess

) : tehnika(

firma,

model,

cena

) {

this->batareya = batareya;

this->vess = vess;

}

void Telephoni()

{

firma = "";

model = "";

cena = 0;

batareya = "";

vess = "";

};

void Telephoni(std::string f, std::string m, int c, std::string b, std::string v)

{

firma = f;

model = m;

cena = c;

batareya = b;

vess = v;

};

void print_Tel()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Тип батареи: " << batareya << std::endl;

std::cout << "Масса: " << vess << std::endl;

system("pause");

}

;

};

Класс MT.

#include <iostream>

#include <string>

#include <sstream>

#include <cstdlib>

#include "Telephon.h"

#include <clocale>

#include <fstream>

using namespace std;

class MT : public Telephon

{

public:

float diag;

float K_sim;

std::string OC;

MT(

std::string firma,

std::string model,

int cena,

std::string batareya,

std::string vess,

float diag,

float K_sim,

std::string OC

) : Telephon(

firma,

model,

cena,

batareya,

vess)

{

this->diag = diag;

this->K_sim = K_sim;

this->OC = OC;

}

void MTi()

{

firma = "";

model = "";

cena = 0;

batareya = "";

vess = "";

diag = 0;

K_sim = 0;

OC = "";

};

void MTi(std::string f, std::string m, int c, std::string b, std::string v, float d, float ks, std::string o)

{

firma = f;

model = m;

cena = c;

batareya = b;

vess = v;

diag = d;

K_sim = ks;

OC = o;

};

void print_MT()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Диагональ: " << diag << std::endl;

std::cout << "Количество симкарт: " << K_sim << std::endl;

std::cout << "ОС: " << OC << std::endl;

system("pause");

};

void print_MTall()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Фирма производителя: " << firma << std::endl;

std::cout << "Модель: " << model << std::endl;

std::cout << "Цена: " << cena << std::endl;

std::cout << "Батарея: " << batareya << std::endl;

std::cout << "Масса: " << vess << std::endl;

std::cout << "Диагональ: " << diag << std::endl;

std::cout << "Количество симкарт: " << K_sim << std::endl;

std::cout << "ОС: " << OC << std::endl;

system("pause");

};

void MTs()

{

setlocale(LC_CTYPE, "rus");

ofstream fout("MT.txt", ios_base::app);

fout << firma << " " << model << " " << cena << " " << batareya << " " << vess << " " << diag << " " << K_sim << " " << OC;

fout.close();

system("pause");

};

void MTo()

{

setlocale(LC_CTYPE, "rus");

char buff[50];

ifstream fin("MT.txt");

while (!fin.eof())

{

fin >> buff;

cout << buff << endl;

}

fin.close();

system("pause");

};

void MTp(char slovo[1024])

{

ifstream fin("MT.txt");

char buffer[1024];

while (!fin.eof)

{

fin.getline(buffer, 1024);

if (strstr(buffer, slovo)) cout << buffer << endl;

};

system("pause");

};

};

Класс Stac.

#include <iostream>

#include <string>

#include <sstream>

#include <cstdlib>

#include "Telephon.h"

#include <clocale>

#include <fstream>

using namespace std;

class Stac : public Telephon

{

public:

bool bespr;

bool pam;

bool n_disp;

Stac(

std::string firma,

std::string model,

int cena,

std::string batareya,

std::string vess,

bool bespr,

bool pam,

bool n_disp

) : Telephon(

firma,

model,

cena,

batareya,

vess)

{

this->bespr = bespr;

this->pam = pam;

this->n_disp = n_disp;

}

void Staci()

{

firma = "";

model = "";

cena = 0;

batareya = "";

vess = "";

bespr = false;

pam = false;

n_disp = false;

};

void Staci(std::string f, std::string m, int c, std::string b, std::string v, bool be, bool p, bool nd)

{

firma = f;

model = m;

cena = c;

batareya = b;

vess = v;

bespr = be;

pam = p;

n_disp = nd;

};

void print_Stac()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Беспроводной: " << bespr << std::endl;

std::cout << "Память: " << pam << std::endl;

std::cout << "Дисплей: " << n_disp << std::endl;

system("pause");

};

void print_Stacall()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Фирма производителя: " << firma << std::endl;

std::cout << "Модель: " << model << std::endl;

std::cout << "Цена: " << cena << std::endl;

std::cout << "Батарея: " << batareya << std::endl;

std::cout << "Масса: " << vess << std::endl;

std::cout << "Беспроводной: " << bespr << std::endl;

std::cout << "Память: " << pam << std::endl;

std::cout << "Дисплей: " << n_disp << std::endl;

system("pause");

};

void Stacs()

{

setlocale(LC_CTYPE, "rus");

ofstream fout("Stac.txt", ios_base::app);

fout << firma << " " << model << " " << cena << " " << batareya << " " << vess << " " << bespr << " " << pam << " " << n_disp;

fout.close();

system("pause");

};

void Staco()

{

setlocale(LC_CTYPE, "rus");

char buff[50];

ifstream fin("Stac.txt");

while (!fin.eof())

{

fin >> buff;

cout << buff << endl;

}

fin.close();

system("pause");

};

void Stacp(char slovo[1024])

{

ifstream fin("Stac.txt");

char buffer[1024];

while (!fin.eof)

{

fin.getline(buffer, 1024);

if (strstr(buffer, slovo)) cout << buffer << endl;

};

system("pause");

};

};

Класс Foto_Video.

#include <iostream>

#include <string>

#include <sstream>

#include <cstdlib>

#include "tehnika.h"

#include <clocale>

class Foto_Video : public tehnika

{

public:

std::string tip_nositel;

std::string stabilizator;

float ves;

Foto_Video(

std::string firma,

std::string model,

int cena,

std::string tip_nositel,

std::string stabilizator,

float ves

) : tehnika(

firma,

model,

cena

) {

this->tip_nositel = tip_nositel;

this->stabilizator = stabilizator;

this->ves = ves;

}

void FVi()

{

firma = "";

model = "";

cena = 0;

tip_nositel = "";

stabilizator = "";

ves = 0;

};

void FVi(std::string f, std::string m, int c, std::string tn, std::string s, float v)

{

firma = f;

model = m;

cena = c;

tip_nositel = tn;

stabilizator = s;

ves = v;

};

void print_FV()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Тип носителя: " << tip_nositel << std::endl;

std::cout << "Стабилизатор: " << stabilizator << std::endl;

std::cout << "Весс: " << ves << std::endl;

system("pause");

}

;

};

Класс Photo.

#include <iostream>

#include <string>

#include <sstream>

#include <cstdlib>

#include "Foto_Video.h"

#include <clocale>

#include <fstream>

using namespace std;

class Photo : public Foto_Video

{

public:

std::string tip_ph;

bool raw;

Photo(

std::string firma,

std::string model,

int cena,

std::string tip_nositel,

std::string stabilizator,

float ves,

std::string tip_ph,

bool raw

) : Foto_Video(

firma,

model,

cena,

tip_nositel,

stabilizator,

ves)

{

this->tip_ph = tip_ph;

this->raw = raw;

}

void Photoi()

{

firma = "";

model = "";

cena = 0;

tip_nositel = "";

stabilizator = "";

ves = 0;

tip_ph = "";

raw = false;

};

void Photoi(std::string f, std::string m, int c, std::string tn, std::string s, float v, std::string tp, bool r)

{

firma = f;

model = m;

cena = c;

tip_nositel = tn;

stabilizator = s;

ves = v;

tip_ph = tp;

raw = r;

};

void print_Ph()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Тип: " << tip_ph << std::endl;

std::cout << "Поддержка RAW: " << raw << std::endl;

system("pause");

};

void print_Phall()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Фирма производителя: " << firma << std::endl;

std::cout << "Модель: " << model << std::endl;

std::cout << "Цена: " << cena << std::endl;

std::cout << "Тип носителя: " << tip_nositel << std::endl;

std::cout << "Стабилизатор: " << stabilizator << std::endl;

std::cout << "Весс: " << ves << std::endl;

std::cout << "Тип: " << tip_ph << std::endl;

std::cout << "Поддержка RAW: " << raw << std::endl;

system("pause");

};

void photos()

{

setlocale(LC_CTYPE, "rus");

ofstream fout("Photo.txt", ios_base::app);

fout << firma << " " << model << " " << cena << " " << tip_nositel << " " << stabilizator << " " << ves << " " << tip_ph << " " << raw;

fout.close();

system("pause");

};

void photoo()

{

setlocale(LC_CTYPE, "rus");

char buff[50];

ifstream fin("Photo.txt");

while (!fin.eof())

{

fin >> buff;

cout << buff << endl;

}

fin.close();

system("pause");

};

void photop(char slovo[1024])

{

ifstream fin("Photo.txt");

char buffer[1024];

while (!fin.eof)

{

fin.getline(buffer, 1024);

if (strstr(buffer, slovo)) cout << buffer << endl;

};

system("pause");

};

};

Класс Video.

#include <iostream>

#include <string>

#include <sstream>

#include <cstdlib>

#include "Foto_Video.h"

#include <clocale>

#include <fstream>

using namespace std;

class Video : public Foto_Video

{

public:

bool vid_p;

bool HD;

Video(

std::string firma,

std::string model,

int cena,

std::string tip_nositel,

std::string stabilizator,

float ves,

bool vid_p,

bool HD

) : Foto_Video(

firma,

model,

cena,

tip_nositel,

stabilizator,

ves)

{

this->vid_p = vid_p;

this->HD = HD;

}

void videoi()

{

firma = "";

model = "";

cena = 0;

tip_nositel = "";

stabilizator = "";

ves = 0;

vid_p = false;

HD = false;

};

void videoi(std::string f, std::string m, int c, std::string tn, std::string s, float v, bool vp, bool hd)

{

firma = f;

model = m;

cena = c;

tip_nositel = tn;

stabilizator = s;

ves = v;

vid_p = vp;

HD = hd;

};

void print_Video()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Видеопоиск: " << vid_p << std::endl;

std::cout << "HD-формат: " << HD << std::endl;

system("pause");

};

void print_Videoall()

{

setlocale(LC_CTYPE, "rus");

std::cout << "Фирма производителя: " << firma << std::endl;

std::cout << "Модель: " << model << std::endl;

std::cout << "Цена: " << cena << std::endl;

std::cout << "Тип носителя: " << tip_nositel << std::endl;

std::cout << "Стабилизатор: " << stabilizator << std::endl;

std::cout << "Весс: " << ves << std::endl;

std::cout << "Видеопоиск: " << vid_p << std::endl;

std::cout << "HD-формат: " << HD << std::endl;

system("pause");

};

void videos()

{

setlocale(LC_CTYPE, "rus");

ofstream fout("Video.txt", ios_base::app);

fout << firma << " " << model << " " << cena << " " << tip_nositel << " " << stabilizator << " " << ves << " " << vid_p << " " << HD;

fout.close();

system("pause");

};

void videoo()

{

setlocale(LC_CTYPE, "rus");

char buff[50];

ifstream fin("Video.txt");

while (!fin.eof())

{

fin >> buff;

cout << buff << endl;

}

fin.close();

system("pause");

};

void videop(char slovo[1024])

{

ifstream fin("Video.txt");

char buffer[1024];

while (!fin.eof)

{

fin.getline(buffer, 1024);

if (strstr(buffer, slovo)) cout << buffer << endl;

};

system("pause");

};

};

1