-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
КМБО-03-21 Мочалов Георгий #42
base: master
Are you sure you want to change the base?
Conversation
electricity/electricity.h
Outdated
bool isConnectedTo(const Object& other) const { | ||
for (auto i = 0; i < getPoleCount(); i++) { | ||
for (auto j = 0; j < other.getPoleCount(); j++) { | ||
if (getPole(i)->connectedObjectPole == other.getPole(j)->name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Неверно.
Вы не проверяте, к какому объекту подключен i-ый полюс текущего объекта, равно как и к какому объекту подключен j-ый полюс other
.
electricity/electricity.h
Outdated
|
||
bool connect(const std::string& poleName, Object& other, const std::string& otherPoleName) { | ||
if (poleName != otherPoleName) { | ||
getPole(poleName)->connectedObject = &other; //const_cast<Object*>(&other) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Было бы неплохо кешировать результат работы getPole()
.
electricity/electricity.h
Outdated
bool disconnect(const std::string& poleName) { | ||
if (getPole(poleName)->connectedObject) { | ||
getPole(poleName)->connectedObject = nullptr; | ||
getPole(poleName)->connectedObjectPole = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вы отключаете полюс со стороны текущего объекта, но не отключаете соответствующий ему полюс другого объекта.
Generator gnr; | ||
gnr.connect("A1", swtch, "A2"); | ||
swtch.connect("A1", lght, "A2"); | ||
lght.connect("A1", gnr, "A2"); | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не хватает демонстрации текущего состояния с выводом на экран.
memhacks/memhacks.cpp
Outdated
} | ||
|
||
/// <summary> | ||
/// Выводит на экран адреса и размеры объекта типа <see cref="B"/> и его содержимого. | ||
/// Можно модифицировать для собственных отладочных целей. | ||
/// </summary> | ||
/// <param name="b">Изучаемый объект</param> | ||
void printInternals(const B& b) { | ||
void printInternals(B& b) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если вам потребовалось убрать модификатор const
чтобы вывести состояние объекта, то что-то явно сделано не так.
memhacks/memhacks.h
Outdated
std::string getBString() const; | ||
void printData(std::ostream& os); | ||
void printData2(std::ostream& os); | ||
virtual std::string* getBStr() = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Геттер не должны изменять состояние объекта и поэтому могут (и должны) помечаться ключевым словом const
.
vectors/vector.cpp
Outdated
using namespace std; | ||
class vector3d { | ||
public: | ||
float data[3]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем-то сделали публичным.
vectors/vector.cpp
Outdated
#include "vector.h" | ||
|
||
using namespace std; | ||
class vector3d { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У вас и здесь класс vector3d
, и в заголовочном файле. Это, в принципе, не может компилироваться.
No description provided.