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
170
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
АФТИ ООП 2013-2014. Лекция I/06
Oleg Dashevskii
October 14, 2013
More Decks by Oleg Dashevskii
See All by Oleg Dashevskii
Лекция № 13. Практическое руководство по разработке
be9
0
1.6k
Лекция № 12. Ещё о проектировании
be9
0
1.5k
Лекция № 11. Принцип отделения интерфейса. «Малое ООП»
be9
0
1.6k
Лекция № 10. Графическая нотация. Принципы LSP и DIP
be9
0
1.6k
Лекция № 9. Отношения между классами. Принцип открытия-закрытия
be9
0
1.5k
Лекция № 8. Хорошие и плохие ОО-программы
be9
0
1.5k
Лекция № 7. algorithm. Исключения
be9
1
1.5k
Лекция № 6. Стандартная библиотека C++. Часть 2
be9
0
1.6k
Лекция № 5. Стандартная библиотека C++. Часть 1
be9
0
1.7k
Other Decks in Education
See All in Education
ちいかわを読め
uchi8977
1
320
形骸化しない社内勉強会の取り組み - オーナーシップの作り方 / In-house study session
soudai
PRO
1
260
0526
cbtlibrary
0
270
AIでアウトプットできる時代だからこそ、自分の言葉で考えることの大切さ / What's Left to Think, When AI Can Write?
masakiokuda
1
230
第2部-高校生とAI活用/high-school2026-2
okana2ki
0
150
学生のうちに考えておきたい信頼の話
suisan
1
770
Modulo : abc
robintux
0
140
セキュリティ担当がいない中小医療機関を院外のRISSはどう支えるべきか / How External RISS Can Help Small Medical Institutions
eller86
0
180
FA26 CLU MS Clinical Psychology New Student Orientation
jdbedics
0
170
遊ぶかね欲しさの犯行(ルビ:労働)です
shirayanagiryuji
0
260
Πλουτοκρατία: Η Τυραννία του Μαμμωνά και η Μεταανθρώπινη Δουλεία
amethyst1
0
310
sepm-training-sample
levii
0
200
Featured
See All Featured
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
410
4 Signs Your Business is Dying
shpigford
187
23k
A Soul's Torment
seathinner
7
3.6k
YesSQL, Process and Tooling at Scale
rocio
174
15k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Building Applications with DynamoDB
mza
96
7.2k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
230
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
290
The SEO Collaboration Effect
kristinabergwall1
1
550
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
370
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
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 ОО-дизайн для задачи сортировки
КОНЕЦ ШЕСТОЙ ЛЕКЦИИ