Skip to content

Commit 04b86ae

Browse files
committed
Массив из 100 экземпляров класса ATM.
1 parent 322b769 commit 04b86ae

9 files changed

+157
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- [Выделение памяти под одномерный динамический массив, оператор new](dynamic-alloc-1d-arr/new-random-array/)
2727
- [Уменьшение всех элементов одномерного массива на среднее значение положительных элементов](dec-arr-el/)
2828
- [Оценка времени работы различных функций сортировки массивов различных типов (целых и вещественных)](sort-algo-time-cmp/)
29+
- [Массив из 100 экземпляров класса ATM](arrays/atms/)
2930

3031
## Динамические структуры данных
3132

arrays/atms/ATMs.dev

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[Project]
2+
FileName=ATMs.dev
3+
Name=ATMs
4+
Type=1
5+
Ver=2
6+
ObjFiles=
7+
Includes=
8+
Libs=
9+
PrivateResource=
10+
ResourceIncludes=
11+
MakeIncludes=
12+
Compiler=
13+
CppCompiler=
14+
Linker=
15+
IsCpp=1
16+
Icon=
17+
ExeOutput=
18+
ObjectOutput=
19+
LogOutput=
20+
LogOutputEnabled=0
21+
OverrideOutput=0
22+
OverrideOutputName=
23+
HostApplication=
24+
UseCustomMakefile=0
25+
CustomMakefile=
26+
CommandLine=
27+
Folders=
28+
IncludeVersionInfo=0
29+
SupportXPThemes=0
30+
CompilerSet=0
31+
CompilerSettings=0000000000000000000000000
32+
UnitCount=1
33+
34+
[VersionInfo]
35+
Major=1
36+
Minor=0
37+
Release=0
38+
Build=0
39+
LanguageID=1033
40+
CharsetID=1252
41+
CompanyName=
42+
FileVersion=
43+
FileDescription=Developed using the Dev-C++ IDE
44+
InternalName=
45+
LegalCopyright=
46+
LegalTrademarks=
47+
OriginalFilename=
48+
ProductName=
49+
ProductVersion=
50+
AutoIncBuildNr=0
51+
SyncProduct=1
52+
53+
[Unit1]
54+
FileName=main.cpp
55+
CompileCpp=1
56+
Folder=
57+
Compile=1
58+
Link=1
59+
Priority=1000
60+
OverrideBuildCmd=0
61+
BuildCmd=
62+

arrays/atms/ATMs.layout

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Editors]
2+
Order=0
3+
Focused=0
4+
[Editor_0]
5+
CursorCol=3
6+
CursorRow=24
7+
TopLine=7
8+
LeftChar=1

arrays/atms/Makefile.win

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Project: ATMs
2+
# Makefile created by Dev-C++ 5.11
3+
4+
CPP = g++.exe
5+
CC = gcc.exe
6+
WINDRES = windres.exe
7+
OBJ = main.o
8+
LINKOBJ = main.o
9+
LIBS = -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib" -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc
10+
INCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include"
11+
CXXINCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++"
12+
BIN = ATMs.exe
13+
CXXFLAGS = $(CXXINCS)
14+
CFLAGS = $(INCS)
15+
RM = rm.exe -f
16+
17+
.PHONY: all all-before all-after clean clean-custom
18+
19+
all: all-before $(BIN) all-after
20+
21+
clean: clean-custom
22+
${RM} $(OBJ) $(BIN)
23+
24+
$(BIN): $(OBJ)
25+
$(CPP) $(LINKOBJ) -o $(BIN) $(LIBS)
26+
27+
main.o: main.cpp
28+
$(CPP) -c main.cpp -o main.o $(CXXFLAGS)

arrays/atms/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Problem Statement
2+
3+
Сделать массив из 100 банкоматов и в каждом чтобы было определенное количество денег.
4+
5+
# Screenshots
6+
7+
![1](screenshot-1.png)
8+
9+
![2](screenshot-2.png)
10+
11+
# References
12+
13+
- [Генератор случайных чисел rand() в С++](http://cppstudio.com/post/339/)

arrays/atms/main.cpp

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <iostream>
2+
#include <cstdlib>
3+
4+
using namespace std;
5+
6+
// Банкомат:
7+
class ATM {
8+
private:
9+
10+
double balance; // количество денег.
11+
12+
public:
13+
14+
ATM() {
15+
this->balance = 0.0;
16+
}
17+
18+
ATM(double startBalance) {
19+
this->balance = startBalance;
20+
}
21+
22+
double getBalance() {
23+
return this->balance;
24+
}
25+
26+
void setBalance(double balanceValue) {
27+
this->balance = balanceValue;
28+
}
29+
};
30+
31+
int main() {
32+
33+
ATM ATMs[100];
34+
35+
for (int i = 0; i < 100; i++) {
36+
ATMs[i].setBalance(rand());
37+
cout << "ATM # " << i + 1 << ": " << ATMs[i].getBalance() << " $" << endl;
38+
}
39+
40+
// Пауза перед выходом:
41+
cin.get();
42+
cin.get();
43+
44+
return 0;
45+
}

arrays/atms/screenshot-1.png

25.2 KB
Loading

arrays/atms/screenshot-2.png

26 KB
Loading
79.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)