Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
АФТИ ООП 2013-2014. Лекция I/06
Search
Oleg Dashevskii
October 14, 2013
Education
0
110
АФТИ ООП 2013-2014. Лекция I/06
Oleg Dashevskii
October 14, 2013
Tweet
Share
More Decks by Oleg Dashevskii
See All by Oleg Dashevskii
Лекция № 13. Практическое руководство по разработке
be9
0
1.4k
Лекция № 12. Ещё о проектировании
be9
0
1.4k
Лекция № 11. Принцип отделения интерфейса. «Малое ООП»
be9
0
1.4k
Лекция № 10. Графическая нотация. Принципы LSP и DIP
be9
0
1.4k
Лекция № 9. Отношения между классами. Принцип открытия-закрытия
be9
0
1.3k
Лекция № 8. Хорошие и плохие ОО-программы
be9
0
1.3k
Лекция № 7. algorithm. Исключения
be9
1
1.3k
Лекция № 6. Стандартная библиотека C++. Часть 2
be9
0
1.4k
Лекция № 5. Стандартная библиотека C++. Часть 1
be9
0
1.4k
Other Decks in Education
See All in Education
Analysis and Validation - Lecture 4 - Information Visualisation (4019538FNR)
signer
PRO
0
1.4k
Поступление в ТОГУ 2024
pnuslide
0
36k
Microsoft Office 365
matleenalaakso
0
1.5k
Data Management and Analytics Specialisation
signer
PRO
0
980
STEAM教育の枠組で行うプログラミング学習
asial_edu
0
210
Pen-based Interaction - Lecture 4 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
1.2k
Gesture-based Interaction - Lecture 8 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
1.2k
心房細動週間ポスター(2024年3月6日)
japanstrokeassociation
0
260
6 занятие. Четыре тактики метода "8 кубиков"бизнес-модели #ideaNN 1.03.2024.
karlov
0
150
WordPressを教える人のための視点と考え方
crebowinfo
0
230
AI教育の未来『おもしろい』を作れる人材の育て方 #東京AI祭
o_ob
1
350
4 занятие. Разбор бизнес-моделей и метод красной нити #ideaNN 9.02.2024.
karlov
0
230
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
73
8.2k
What's new in Ruby 2.0
geeforr
337
31k
Happy Clients
brianwarren
92
6.4k
Statistics for Hackers
jakevdp
789
220k
Clear Off the Table
cherdarchuk
84
310k
Done Done
chrislema
178
15k
Fireside Chat
paigeccino
21
2.6k
Code Review Best Practice
trishagee
55
15k
How STYLIGHT went responsive
nonsquared
92
4.8k
Raft: Consensus for Rubyists
vanstee
132
6.3k
Why Our Code Smells
bkeepers
PRO
331
56k
How GitHub (no longer) Works
holman
304
140k
Transcript
ОБЪЕКТНО- ОРИЕНТИРОВАННОЕ ПРОГРАММИРОВАНИЕ Лекция № 6 14.10.2013 г.
В ПРОШЛОЙ СЕРИИ • Single responsibility principle (SRP). • Наследование,
агрегация, композиция, ассоциация. • Задача 1. Применение ООП к stdio.h. • Задача 2. «Малое ООП». Задача линейной аппроксимации множества точек.
ПОТОКИ В C++ ios_base ios istream ostream iostream istringstream ifstream
filebuf
ПОТОКИ В QT QObject QIODevice QFile QTextStream QBuffer QProcess QAbstract
Socket и др.
class LinearRegression { public: LinearRegression(const QPointF *_points, int _size); LinearRegression(const
QVector<QPointF> &_points); // y=Ax+B double a(); double b(); QPointF point(double x) { return QPointF(x, a()*x+b()); } double mse(); double std(); protected: void calculate(); /****/ const QPointF *points; int size; bool ready; double _a, _b; };
ЗАДАЧА 2’ Проектирование класса для линейной экспоненциальной аппроксимации набора точек
class BaseRegression { public: BaseRegression(const QPointF *_points, int _size); BaseRegression(const
QVector<QPointF> &_points); virtual double y(double x)=0; QPointF point(double x) { return QPointF(x, y(x)); } double mse(); double std(); protected: /****/ const QPointF *points; int size; };
class ExponentialRegression : public BaseRegression { public: ExponentialRegression(const QVector<QPointF> &points);
// y=A*exp(B*x) double a(); double b(); double y(double x) { return a()*exp(b()*x); } protected: void calculate(); /****/ bool ready; double _a, _b; };
void ExponentialRegression::calculate() { QVector<QPointF> logpoints(size); for (int i = 0;
i < size; ++i) logpoints[i] = QPointF(points[i].x(), log(fabs(points[i].y()))); LinearRegression lr(logpoints); _b = lr.a(); _a = exp(lr.b()); if (size > 0 && points[0].y() < 0) _a *= -1; ready = true; }
void ExponentialRegression::calculate() { QVector<QPointF> logpoints(size); for (int i = 0;
i < size; ++i) logpoints[i] = QPointF(points[i].x(), log(fabs(points[i].y()))); LinearRegression lr(logpoints); _b = lr.a(); _a = exp(lr.b()); if (size > 0 && points[0].y() < 0) _a *= -1; ready = true; } Композиция
ЗАДАЧА 3 ОО-дизайн для задачи сортировки
КОНЕЦ ШЕСТОЙ ЛЕКЦИИ