Welcome Back to my Blog!
Where we recap what we did the previous week, I was moving from home to college to start my spring semester, so it's going to be shorter than last time, but let's get into it.
Quote Of the Week
"Sorry your dog died, I guess."
- Redditor
This week we dabbled in C++, starting a new chapter of the book so let's start with that.
C++
This week we started Chapter 11, which is called "Planning and Building Objects". I made it to the "Building Hierarchies" subsection. Previous to this section, we went over how to properly use classes and children functions, methods, and protected vs. private variables. It was more conceptual writing rather than code, so I only have this "Dog Health" script to show. I would have gotten farther, but due to the hectic week, I could only get so far.
Code
#include <iostream>using namespace std;class MyDog {protected: //This is the perfered method of making non-publically accessable values in C++string _name;int _weight = 300;bool _isHealthy = false;public://Propertiesstring getName(){return _name;}int getWeight(){return _weight;}void setWeight(int weight){if (weight > 0){_weight = weight;}}void setIsHealthy(bool isHealty){if (_weight > 200){_isHealthy = false;}else{_isHealthy = true;}}//MethodsMyDog(string name);void DoDogRun();};MyDog::MyDog(string name){if (name.length() == 0) throw "Error: Couldn't create my Dog.";MyDog::_name = name;}void MyDog::DoDogRun(){if (MyDog::_isHealthy)cout << MyDog::_name << "is running!" << endl;else if (MyDog::_weight > 200)cout << MyDog::_name << "is too fat to run!" << endl;elsecout << MyDog::_name << "Is unhealty; see vet first" << endl;}int main() {MyDog* thisDog;try {thisDog = new MyDog("Fred");}catch (const char* msg) {cerr << msg << endl;return -1;}cout << thisDog->getName() << "needs excercise" << endl;thisDog->DoDogRun();thisDog->setWeight(100);thisDog->DoDogRun();thisDog->setIsHealthy(true);thisDog->DoDogRun();delete thisDog;thisDog = 0;return 0;}
Python to Executable
Now I also researched how to turn a .py file into a .exe to facilitate a transfer of my programs without the need for people to download python and have all the necessary scripts. The best and easiest way to do this is to use an application called "auto-py-to-exe" a quick google search should show you a documentation page and a youtube video or two on it.
The program I put into an executable was the PPCC (Personal Pokemon Card Creator) that was previously shown here. I even made a new icon for it; take a look.
If you'd like to see the functionality of this card creator, you can take a look at my post about it here (https://patricksbb.blogspot.com/2022/12/personal-pokemon-card-creator.html). I will release this ".exe" file soon, so please be on the lookout; if you'd like to see the raw code, you can go to my GitHub page linked above. If you use the code, please credit it to me.
Minecraft
We have the server up and joinable, and the starting area has been fully completed, as shown in the picture above. I will keep you posted and maybe showcase the builds of the week.
That's it for last week. Be sure to come back next Monday to find another post at the same spot,
the same place until then
-Peaceš£
No comments:
Post a Comment