Форум программистов, компьютерный форум, киберфорум
С++ для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Frusya
1

программа "База данных футбольной команды"

10.02.2013, 22:51. Показов 733. Ответов 0
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
задали курсовую сделать. кое-что уже реализовала. но зашла в тупик. нужно чтобы было много игр с разными командами. подскажите как это можно реализовать.

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#include <iostream>
#include <string>
#include <fstream>
#include <list>
#include <Windows.h>
using namespace std;
 
class Footballer
{
    string Name;
    string Surname;
    int Number;
    string Position;//амплуа
public:
    Footballer(string _Name="", string _Surname="", string _Position="", int _Number=0)
    {
        Name=_Name;
        Surname=_Surname;
        Number=_Number;
        Position=_Position;
    }
    string getName() const
    {
        return Name;
    }
    void setName(string _Name)
    {
        Name=_Name;
    }
    string getSurname() const
    {
        return Surname;
    }
    void setSurname(string _Surname)
    {
        Surname=_Surname;
    }
    string getPosition() const
    {
        return Position;
    }
    void setPosition(string _Position)
    {
        Position=_Position;
    }
    friend ostream & operator<<(ostream & os, const Footballer & Obj);
    friend ofstream &operator<<(ofstream &os, const Footballer &Obj);
 
};
ostream & operator<<(ostream & os, const Footballer & Obj)
{
    os<<"Имя: "<<Obj.Name<<" ";
    os<<"Фамилия: "<<Obj.Surname<<" ";
    os<<"Амплуа: "<<Obj.Position<<" ";
    os<<"Номер: "<<Obj.Number;
    return os;
}
ofstream &operator<<(ofstream &os, const Footballer & Obj)
{
        os<<Obj.Name.c_str()<<endl;
        os<<Obj.Surname.c_str()<<endl;
        os<<Obj.Position.c_str()<<endl;
        os<<Obj.Number<<endl;
        return os;
}
class FC
{
    string Name_FC;
    list <Footballer> fc;
public:
    FC(string _Name_FC="")
    {
        Name_FC=_Name_FC;
    }
    void AddFootballer(const Footballer & footballer)
    {
        fc.push_back(footballer);
    }
    friend ostream & operator<<(ostream & os, const FC & Obj);
    friend ofstream & operator<<(ofstream &os, const FC &Obj);
 
    void Write(string file)
    {
        ofstream os(file);
        if(os.is_open())
        {       
            os<<*this;
            os.close();
        }
        else
        {
            cout<<"Ошибка открытия файла "<<file<<endl;
        }       
    }
    void Read(string file)
    {   
        ifstream is(file);
        if(is.is_open())
        {           
            getline(is, Name_FC);
            string footballerName;
            string footballerSurname;
            string footballerPosition;
            while(getline(is, footballerName))
            {               
                string footballerNumber;
                fflush(stdin);
                getline(is, footballerNumber);
                fflush(stdin);
                int number  = atoi(footballerNumber.c_str());
                Footballer footballer(footballerName, footballerSurname, footballerPosition, number);
                fc.push_back(footballer);               
            }
            is.close();
        }
        else
        {
            cout<<"Ошибка открытия файла "<<file<<endl;
        }
    }   
 
};
ostream & operator<<(ostream & os, const FC & Obj)
{
    os<<"Команда: "<<Obj.Name_FC<<endl;
    
    for(list<Footballer>::const_iterator it = Obj.fc.begin(); it!= Obj.fc.end(); it++)
    {
        os<<*it<<endl;
    }
    return os;
}
ofstream & operator<<(ofstream &os, const FC &Obj)
{
    os<<Obj.Name_FC.c_str()<<endl;
    for(list<Footballer>::const_iterator it=Obj.fc.begin(); it!=Obj.fc.end(); it++)
    {
        os<<*it;
    }
    return os;
}
class Judge
{
    string Name;
    string Type;
public:
    Judge(string _Name="", string _Type="")
    {
        Name=_Name;
        Type=_Type;
    }
    string getName() const
    {
        return Name;
    }
    void setName(string _Name)
    {
        Name=_Name;
    }
    string getType() const
    {
        return Type;
    }
    void setType(string _Type)
    {
        Type=_Type;
    }
    friend ostream & operator<<(ostream & os, const Judge & Obj);
    friend ofstream & operator<<(ofstream &os, const Judge &Obj);
};
ostream & operator<<(ostream & os, const Judge & Obj)
{
    os<<"Имя судьи: "<<Obj.Name;
    os<<"Вид: "<<Obj.Type;
    return os;
}
ofstream & operator<<(ofstream & os, const Judge & Obj)
{
        os<<Obj.Name.c_str()<<endl;
        os<<Obj.Type.c_str()<<endl;
        return os;
 
}
class Game
{
    string Team1;
    string Team2;
    int res1;
    int res2;
    string Town;
    string date;
    FC fc;
    list<FC> f1;
    list <Judge> jd;
public:
    Game(string _Team1="", string _Team2="", string _date="", string _Town="", int _res1=0, int _res2=0)
    {
        Team1 = _Team1;
        Team2 = _Team2;
        date = _date;
        Town = _Town;
        res1 = _res1;
        res2 = _res2;
    }
    void AddJudge(const Judge & judge)
    {
        jd.push_back(judge);
    }
    friend ostream &operator<<(ostream &os, const Game &Obj);
    friend ofstream &operator<<(ofstream &os, const Game &Obj);
 
    void Write(string file)
    {
        ofstream os(file);
        if(os.is_open())
        {       
            os<<*this;
            os.close();
        }
        else
        {
            cout<<"Ошибка открытия файла "<<file<<endl;
        }       
    }
    void Read(string file)
    {   
        ifstream is(file);
        if(is.is_open())
        {           
            getline(is, Team1);
            getline(is, Team2);
            getline(is, date);
            getline(is, Town);
            string judgeName;
            string judgeType;
            while(getline(is, judgeName))
            {               
                string judgeType;
                fflush(stdin);
                getline(is, judgeType);
                fflush(stdin);
                Judge judge(judgeName, judgeType);
                jd.push_back(judge);                
            }
            is.close();
        }
        else
        {
            cout<<"Ошибка открытия файла "<<file<<endl;
        }
    }   
};
ofstream &operator<<(ofstream &os, const Game &Obj)
{
    os<<Obj.Team1.c_str()<<"-"<<Obj.Team2.c_str()<<endl;
    os<<Obj.date.c_str()<<endl;
    os<<Obj.Town.c_str()<<endl;
    os<<Obj.res1<<":"<<Obj.res2<<endl;
    return os;
    for(list<FC>::const_iterator it = Obj.f1.begin(); it!= Obj.f1.end(); it++)
    {
        os<<*it<<endl;
    }
    return os;
    for(list<Judge>::const_iterator it = Obj.jd.begin(); it!= Obj.jd.end(); it++)
    {
        os<<*it<<endl;
    }
    return os;
}
ostream &operator<<(ostream &os, const Game &Obj)
{
    os<<"Встреча: "<<Obj.Team1<<"-"<<Obj.Team2<<endl;
    os<<"Дата проведения матча: "<<Obj.date<<endl;
    os<<"Место проведения: "<<Obj.Town<<endl;
    os<<"Результат игры: "<<Obj.res1<<":"<<Obj.res2<<endl;
    return os;
    for(list<FC>::const_iterator it = Obj.f1.begin(); it!= Obj.f1.end(); it++)
    {
        os<<*it<<endl;
    }
    return os;
 
    for(list<Judge>::const_iterator it = Obj.jd.begin(); it!= Obj.jd.end(); it++)
    {
        os<<*it<<endl;
    }
    return os;
}
 
 
void main()
{   
    SetConsoleOutputCP(1251);
    SetConsoleCP(1251);
    Footballer footballer[3]={Footballer("Евгений", "Хачериди", "защитник", 34), Footballer("Артём","Милевский","нападающий",10), Footballer("Александр", "Шовковский", "голкипер", 1)};
    Judge judge[3]={Judge ("Иван Смирнов", "1-ой боковой арбитр"), Judge("Николай Самсонов", "главный арбитр"), Judge("Арсен Микоян", "2-ой боковой арбитр")};
    FC fc("Динамо К");
    for(int i=0; i<3; i++)
    {
        fc.AddFootballer(footballer[i]);
    }
    cout<<fc;
    Game game("Днепр Д", "Карпаты Л", "27.10.2012", "Днепропетровск", 1, 0);
    for(int i=0; i<3; i++)
    {
        game.AddJudge(judge[i]);
    }
    game.Write("data123.txt");
    fc.Write("data.txt");
    fc.Read("data.txt");
    game.Read("data123.txt");
}
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
10.02.2013, 22:51
Ответы с готовыми решениями:

В массиве записаны результаты N игр футбольной команды. Определить количество выигрышей, количество проигрышей и количество ничьих данной команды.
Помогите пожалуйста решить задачу. НА С# труда не составляет а вот на С++ не получается. 1. В...

Во время футбольной игры формируется файл, распечатать фамилии 3 самых результативных игроков команды
Во время футбольной игры формируется файл, который включает фамилию игрока и количество набранных...

Массив "Результаты футбольной команды"
Всем привет!!!Пожалуйста помогите с задачкой!!! Задание: В массиве записаны результаты 20 игр...

Программа следящая за футбольной игрой
ребят,спасайте полный ***** препод дал задание на практику но как это обычно бывает в наших инстах...

Вывод на экран названия футбольной команды
Помогите пожалуйста составить программу которая запрашивает название футбольной команды и...

0
10.02.2013, 22:51
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
10.02.2013, 22:51
Помогаю со студенческими работами здесь

Программа расчета количества очков футбольной команды
Вдруг кто-то поможет написать следующую программу? Есть университетская команда, которая сыграла...

В массиве записаны результаты 20 игр футбольной команды. Определить количество выигрышей, количество ничьих и количество проигрышей данной команды
В массиве записаны результаты 20 игр футбольной команды(если игра окончилась выигрышем данной...

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

Обработать данные о игре футбольной команды
Даны 20 пар однозначных чисел. Первое число каждой пары означает количество мячей, забитых...

Определить количество выигрышей и проигрышей футбольной команды
Кол-во мячей, забитых и пропущенных футбольной командой в каждой из 22-х игр, записано в массиве,...

В массиве записаны результаты 20 игр футбольной команды
3. Одномерные массивы В массиве записаны результаты 20 игр футбольной команды (если игра...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
1
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru