Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
курсовая программирование С++ Ч.Ю.С..doc
Скачиваний:
5
Добавлен:
16.09.2019
Размер:
554.5 Кб
Скачать

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

Программная документация должна содержать пояснительную записку к курсовой работе и графическую часть.

6. Технико-экономические показатели

В результате внедрения разработанного ПО предполагается увеличить информационность института.

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

7.1. Стадия аналитической разработки:

  • ознакомление с теоретическим материалом;

  • аналитическая обработка теоретической информации.

  • объектно-ориентированный анализ;

  • разработка диаграммы объектов;

  • разработка диаграммы последовательности;

  • объектно-ориентированное проектирование;

  • разработка диаграммы классов.

7.2. Стадия программной разработки:

  • разработка классов и отдельных модулей программы;

  • отладка полученных классов и модулей;

  • объединение структур и формирование единой программы;

  • тестирование и получение результатов работы программы.

7.3. Стадия аналитического анализа:

  • анализ данных, полученных в результате работы программы;

  • выработка рекомендаций по увеличению эффективности использования объекта моделирования.

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

8.1. При сдаче работы производится демонстрация разработанной программы на контрольном примере.

8.2. Копии всех документов включают:

  • исходный текст программы;

  • загрузочные модули (скомпилированная программа и файлы с входными данными);

  • текстовую и графическую документацию.

Копии передаются на магнитном носителе преподавателю не позднее, чем за 3 дня до защиты.

Приложение 2. Листинг программы

CBuy.h

#include <fstream>

#include <vector>

#include "CRastenie.h"

class CBuy

{

private:

int Number;

int Sum;

char * Otdel;

std::vector <CRastenie *> vr;

public:

int get_Number(void);

void set_Number(int ANumber);

int get_Sum(void);

void set_Sum(int ASum);

char * get_Otdel(void);

void set_Otdel(char * AOtdel);

CBuy();

CBuy(CBuy & As);

CBuy(int ANumber,int ASum,char * AOtdel);

~CBuy ();

void Read();

void Write();

void ReadF(std::ifstream &f);

void WriteF(std::ofstream &f);

void WriteV( );

void WriteFV(std::ofstream &f);

void ReadFV(std::ifstream &f);

void AddRastenieInBuy(CRastenie * r);

int CountRastenieInBuy ( );

};

CRastenie.h

#ifndef __CRastenie__

#define __CRastenie__

#include <fstream>

class CRastenie

{

private:

char Name [30];

char Tip [50];

char Tehnologi [120];

public:

char * get_Name(void);

void set_Name(char * AName);

char * get_Tip(void);

void set_Tip(char * ATip);

char * get_Tehnologi(void);

void set_Tehnologi(char * ATehnologi);

CRastenie();

CRastenie(CRastenie & As);

CRastenie(char * AName,char * ATip,char * ATehnologi);

void Read();

void Write();

void ReadF(std::ifstream &f);

void WriteF(std::ofstream &f);

};

#endif

CSort.h

#include <fstream>

#include "CRastenie.h"

class CSort:public CRastenie

{

private:

char NameSort[50];

char Description[300];

char Frost[3];

int Year;

public:

char * get_NameSort(void);

void set_NameSort(char * AnewNameSort);

char * get_Description(void);

void set_Description(char * AnewDescription);

char * get_Frost(void);

void set_Frost(char * AnewFrost);

int get_Year(void);

void set_Year(int AnewYear);

CSort();

CSort(char * AName,char * ATip,char * ATehnologi,char * ANameSort,char * ADescription,char * AFrost,int AYear);

~CSort();

void Write();

void Read();

void WriteF(std::ofstream & f);

void ReadF(std::ifstream & f);

};

b.cpp

#include "stdafx.h"

#include <string.h>

#include "CBuy.h"

#include <iostream.h>

extern std::vector <CBuy *> v;

extern std::vector <CRastenie *> w;

int CBuy::get_Number(void)

{ return Number;}

void CBuy::set_Number(int ANumber)

{ Number = ANumber;}

int CBuy::get_Sum(void)

{ return Sum;}

void CBuy::set_Sum(int ASum)

{ Sum = ASum;}

char * CBuy::get_Otdel(void)

{ return Otdel;}

CBuy::CBuy()

{

Number = 10;

Sum = 370;

Otdel= new char [8];

strcpy( Otdel ,"Flowers");

}

CBuy::CBuy(CBuy & As)

{

Number = As.Number;

Sum = As.Sum;

Otdel= new char [strlen( As.Otdel)+1];

strcpy(Otdel, As.Otdel);

}

CBuy::CBuy(int ANumber, int ASum, char * AOtdel)

{

Number = ANumber;

Sum = ASum;

Otdel= new char [strlen( AOtdel)+1];

strcpy(Otdel, AOtdel);

}

CBuy::~CBuy()

{

delete [ ] Otdel;

}

void CBuy::set_Otdel(char * AOtdel)

{

if (Otdel!=0)

delete[] Otdel;

Otdel = new char[strlen(AOtdel)+1];

strcpy(Otdel, AOtdel);

}

void CBuy::Read(void)

{

cout << "vvedite informazhiy o pokupke" << endl;

cout << "vvedite Number" << endl;

cin >> Number;

cout << "vvedite Sum" << endl;

cin >> Sum;

cout << "vvedite Otdel" << endl;

char s[1000];

cin >> s;

Otdel = new char [strlen(s)+1];

strcpy(Otdel, s);

int i;

int command = 4;

CRastenie * Temp100;

while (command != 0)

{ cout << "Please enter operation..." << endl;

cout << "1. Add new Rastenie in Buy" << endl;

cout << "2. Add Rastenie in Buy" << endl;

cout << "0. Exit from this menu" << endl;

cin >> command;

if (command==1)

{ Temp100=new CRastenie();

Temp100->Read();

w.push_back(Temp100 );

AddRastenieInBuy(Temp100);

}

else if (command==2)

{

cout << "Vvedite nomer rastenija v glob-spiske";

cin >> i;

AddRastenieInBuy (w[i]);

}

else

{cout << "Invalid command" << endl;

}

}

}

void CBuy::ReadF(std::ifstream &f)

{

char s[1000];

f >> Number >> Sum >> s;

Otdel= new char [strlen(s)+1];

strcpy(Otdel, s);

ReadFV(f);

}

void CBuy::Write(void)

{

cout << "informazhiy o pokupke" << endl;

cout << "Number: " << Number <<endl;

cout << "Sum: " << Sum << endl;

cout << "Otdel: " << Otdel << endl;

}

void CBuy::WriteF(std::ofstream &f)

{

f << Number << std::endl << Sum << std::endl << Otdel << std::endl;

WriteFV( f );

}

void CBuy::AddRastenieInBuy(CRastenie * r)

{ vr.push_back( r );

}

void CBuy::WriteV( )

{cout << "Kolichestvo rasteni: " <<

CountRastenieInBuy() << endl;

for(int i =0; i< CountRastenieInBuy(); i++)

{vr[i]->Write( );

}

}

void CBuy::WriteFV( std::ofstream &f)

{ f << CountRastenieInBuy () << std::endl;

for(int i =0; i< CountRastenieInBuy (); i++)

{for(int n = 0; n<w.size(); n++)

{ if(w[n] == vr[i]) break;

}

f << n << std::endl;

}

}

void CBuy::ReadFV(std::ifstream & f )

{ int N2, n2;

f >> N2;

for(int i = 0; i < N2; i++)

{

f >> n2;

vr.push_back(w[n2]);

}

}

int CBuy::CountRastenieInBuy ( )

{ return vr.size();

}

Cr.cpp

#include "stdafx.h"

#include <string.h>

#include "CBuy.h"

#include <iostream.h>

char * CRastenie::get_Name (void)

{ return Name;}

void CRastenie::set_Name (char * AName)

{ strcpy (Name,AName);}

char * CRastenie::get_Tip (void)

{ return Tip;}

void CRastenie::set_Tip (char * ATip)

{ strcpy(Tip ,ATip);}

char * CRastenie::get_Tehnologi(void)

{ return Tehnologi;}

void CRastenie::set_Tehnologi (char * ATehnologi)

{ strcpy (Tehnologi ,ATehnologi);}

CRastenie::CRastenie()

{ strcpy( Name ,"Tomato");

strcpy( Tip ,"Seeds");

strcpy( Tehnologi ,"To_plant_in_the_earth_and_to_water");

}

CRastenie::CRastenie(CRastenie & As)

{ strcpy( Name, As.Name);

strcpy(Tip, As.Tip);

strcpy( Tehnologi, As.Tehnologi);

}

CRastenie::CRastenie(char * AName,char * ATip,char * ATehnologi)

{ strcpy( Name ,AName);

strcpy(Tip ,ATip);

strcpy( Tehnologi ,ATehnologi);

}

void CRastenie::Read(void)

{

cout << "vvedite informazhiy o rastenie" << endl;

cout << "vvedite Name" << endl;

cin >> Name;

cout << "vvedite Tip" << endl;

cin >> Tip;

cout << "vvedite Tehnologi" << endl;

cin >> Tehnologi;

}

void CRastenie::ReadF(std::ifstream &f)

{

f >> Name >> Tip >> Tehnologi ;

}

void CRastenie::Write(void)

{

cout << "informazhiy o rastenie" << endl;

cout << "Name: " << Name <<endl;

cout << "Tip: " << Tip << endl;

cout << "Tehnologi: " << Tehnologi << endl;

}

void CRastenie::WriteF(std::ofstream &f)

{ f << Name << std::endl << Tip << std::endl << Tehnologi << std::endl;

}

S.cpp

#include "stdafx.h"

#include <string.h>

#include "CSort.h"

#include "CRastenie.h"

#include <iostream.h>

char * CSort::get_NameSort(void)

{ return NameSort;}

void CSort::set_NameSort(char * ANameSort)

{ strcpy( NameSort ,ANameSort);}

char * CSort::get_Description(void)

{ return Description;}

void CSort::set_Description(char * ADescription)

{ strcpy( Description ,ADescription);}

char * CSort::get_Frost(void)

{ return Frost;}

void CSort::set_Frost(char * AFrost)

{ strcpy( Frost ,AFrost);}

int CSort::get_Year(void)

{ return Year;}

void CSort::set_Year(int AYear)

{ Year = AYear;}

CSort::CSort():CRastenie()

{

strcpy( NameSort ,"Kivi");

strcpy( Description ,"Leaves_roundish,with_slightly_pointed_top,dark_green_colour,with_a_glossy_surface_and_the_rough_bottom_party.Fruits_large,weight_from_80_to_150,the_oval_form.");

strcpy( Frost ,"yes");

Year = 2011;

}

CSort::CSort(char * AName,char * ATip,char * ATehnologi,char * ANameSort,char * ADescription,char * AFrost,int AYear):CRastenie(AName,ATip,ATehnologi)

{

strcpy( NameSort ,ANameSort);

strcpy( Description ,ADescription);

strcpy( Frost ,AFrost);

Year = AYear;

}

CSort::~CSort()

{

}

void CSort::Read(void)

{

CRastenie::Read();

cout << "vvedite informazhiy o sorte" << endl;

cout << "vvedite NameSort" << endl;

cin >> NameSort;

cout << "vvedite Description" << endl;

cin >> Description;

cout << "vvedite Frost" << endl;

cin >> Frost;

cout << "vvedite Year"<< endl;

cin >> Year;

}

void CSort::ReadF(std::ifstream & f)

{

CRastenie::ReadF(f);

f >> NameSort >> Description >> Frost >> Year;

}

void CSort::Write(void)

{

cout << endl;

CRastenie::Write();

cout << "informazhiy o sorte" << endl;

cout << "NameSort: " << NameSort << endl;

cout << "Description: " << Description << endl;

cout << "Frost: " << Frost << endl;

cout << "Year: "<< Year << endl;

}

void CSort::WriteF(std::ofstream & f)

{

CRastenie::WriteF(f);

f << NameSort << std::endl << Description << std::endl << Frost << std::endl << Year << std::endl;

}

buy.cpp

#include "stdafx.h"

#include <string.h>

#include "CBuy.h"

#include "CRastenie.h"

#include "CSort.h"

#include <iostream.h>

#include <fstream>

#include <vector>

void ReadFAllCBuy(char * fn, std::vector <CBuy *> & v)

{ std::ifstream f(fn);

int N;

f>>N;

CBuy *b;

for(int i=0; i<N; i++)

{ b = new CBuy();

b->ReadF(f);

v.push_back(b);

}

f.close();

}

void WriteFAllCBuy(char * fn, std::vector <CBuy *> v)

{ std::ofstream f(fn);

f<<v.size()<< std::endl;

for(int i=0; i<v.size(); i++)

{ v[i]->WriteF(f);

}

f.close();

}

void WriteAllCBuy(std::vector <CBuy *> v)

{ cout<<"kolich buy =" <<v.size()<< endl;

for(int i=0; i<v.size(); i++)

{ v[i]->Write();

}

}

void ReadFAllCRastenie(char * fn, std::vector < CRastenie *> & w)

{ std::ifstream f(fn);

int N;

f>>N;

CRastenie *m;

for(int i=0; i<N; i++)

{ m = new CRastenie();

m->ReadF(f);

w.push_back(m);

}

f.close();

}

void WriteFAllCRastenie(char * fn, std::vector < CRastenie *> w)

{ std::ofstream f(fn);

f<<w.size()<< std::endl;

for(int i=0; i<w.size(); i++)

{ w[i]->WriteF(f);

}

f.close();

}

void WriteAllCRastenie(std::vector <CRastenie *> w)

{ cout<<"kolich rasteni =" <<w.size()<< endl;

for(int i=0; i<w.size(); i++)

{ w[i]->Write();

}

}

void ReadFAllCSort(char * fn, std::vector <CSort *> & vs)

{ std::ifstream f(fn);

int N;

f>>N;

CSort *o;

for(int i=0; i<N; i++)

{ o = new CSort();

o->ReadF(f);

vs.push_back(o);

}

f.close();

}

void WriteFAllCSort(char * fn, std::vector <CSort *> vs)

{ std::ofstream f(fn);

f<<vs.size()<< std::endl;

for(int i=0; i<vs.size(); i++)

{ vs[i]->WriteF(f);

}

f.close();

}

void WriteAllCSort(std::vector <CSort *> vs)

{ cout<<"kolich sort =" <<vs.size()<< endl;

for(int i=0; i<vs.size(); i++)

{ vs[i]->Write();

}

}

std::vector <CBuy *> v;

std::vector <CRastenie *> w;

std::vector <CSort *> vs;

void main(void)

{

ReadFAllCBuy ("buy.txt", v);

ReadFAllCRastenie ("rastenie.txt", w);

ReadFAllCSort ("sort.txt", vs);

char fn[600];

int kod;

do{ cout << "1. Buy File -> vector" << endl;

cout << "2. Buy vector -> File" << endl;

cout << "3. Buy vector -> Display" << endl;

cout << "4. Add Buy to vector" << endl;

cout << "5. Rastenie File -> vector" << endl;

cout << "6. Rastenie vector -> File" << endl;

cout << "7. Rastenie vector -> Display" << endl;

cout << "8. Add Rastenie to vector" << endl;

cout << "9. Sort File -> vector" << endl;

cout << "10.Sort vector -> File" << endl;

cout << "11.Sort vector -> Display" << endl;

cout << "12.Add Sort to vector" << endl;

cout << "0. Exit" << endl;

cout << "Select: 1-12 or 0." << endl;

cin >> kod;

switch (kod)

{ case 1:

cout << "Input File name: " << endl;

cin >> fn;

ReadFAllCBuy(fn, v);

break;

case 2:

cout << "Input File name: " << endl;

cin >> fn;

WriteFAllCBuy(fn, v);

break;

case 3:

WriteAllCBuy(v);

break;

case 4:

CBuy * b;

b=new CBuy;

b->Read();

v.push_back(b);

break;

case 5:

cout << endl;

cout << "Input File name: " << endl;

cin >> fn;

ReadFAllCRastenie(fn, w);

break;

case 6:

cout << endl;

cout << "Input File name: " << endl;

cin >> fn;

WriteFAllCRastenie(fn, w);

break;

case 7:

WriteAllCRastenie(w);

break;

case 8:

CRastenie *a;

a=new CRastenie;

a->Read();

w.push_back(a);

break;

case 9:

cout << "Input File name: " << endl;

cin >> fn;

ReadFAllCSort(fn, vs);

break;

case 10:

cout << "Input File name: " << endl;

cin >> fn;

WriteFAllCSort(fn, vs);

break;

case 11:

WriteAllCSort(vs);

break;

case 12:

CSort * o;

o=new CSort;

o->Read();

vs.push_back(o);

break;

}

} while (kod > 0);

cout << "GOOD BYE"<< endl;

}

22