Difference between revisions of "Beginner C++ Game Programming Tutorial 12"

From Chilipedia
Jump to: navigation, search
(Encapsulation)
m (Text replacement - "http://www.planetchili.net/" to "https://www.planetchili.net/")
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
Here we learn about the concept of encapsulation (ask your mom where she keeps the Vicodin!), which is the main principle behind object oriented programming (so listen the fuck up eh?). We also learn how to construct shit, and how to make our shit private.
 
Here we learn about the concept of encapsulation (ask your mom where she keeps the Vicodin!), which is the main principle behind object oriented programming (so listen the fuck up eh?). We also learn how to construct shit, and how to make our shit private.
 +
 +
== <span style="color:pink">Important Note</span> ==
 +
Visual Studio has a <cool feature> wherein when you use "quick actions... -> move definition location" on a constructor, it adds a goddamn <code>inline</code> keyword which fucks the whole goddamn works up! D:< This is fixed in the homework solution, but if you are attempting the homework before peeking (as you should be), then this could fuck you up royally. Keep it in mind.
  
 
== Concepts Taught ==
 
== Concepts Taught ==
Line 11: Line 14:
  
 
== Video Timestamp Index ==
 
== Video Timestamp Index ==
Coming soon!
+
* Intro [https://www.youtube.com/watch?v=QUBiAUKfVhM&t=0m0s 0:00]
 +
* Encapsulation: Difference between <code>public</code> and <code>private</code> data members [https://www.youtube.com/watch?v=QUBiAUKfVhM&t=0m55s 0:55]
 +
* Poo class: Making member data private [https://www.youtube.com/watch?v=QUBiAUKfVhM&t=2m43s 2:43]
 +
* Important note on "Getters" and "Setters" [https://www.youtube.com/watch?v=QUBiAUKfVhM&t=5m0s 5:00]
 +
* Advantages of <code>private</code> member data with a getter and setter, as opposed to just <code>public</code> member data [https://www.youtube.com/watch?v=QUBiAUKfVhM&t=7m7s 7:07]
 +
* Constructors: setting values during object initialization [https://www.youtube.com/watch?v=QUBiAUKfVhM&t=9m30s 9:30]
 +
* Class initializer list: Initializing embedded objects (Poo objects inside a Game object) [https://www.youtube.com/watch?v=QUBiAUKfVhM&t=12m34s 12:34]
 +
* Class initializer list order must correspond to the order of data member declaraion [https://www.youtube.com/watch?v=QUBiAUKfVhM&t=17m10s 17:10]
 +
* Visual Studio tricks: Quick actions -> Move definition location, but with a little brainfucky surprize you will learn about very soon [https://www.youtube.com/watch?v=QUBiAUKfVhM&t=19m59s 19:59]
 +
* Reasons to properly encapsulate class member data [https://www.youtube.com/watch?v=QUBiAUKfVhM&t=20m52s 20:52]
 +
* Homework [https://www.youtube.com/watch?v=QUBiAUKfVhM&t=30m10s 30:10]
  
 
== Homework ==
 
== Homework ==
# Encapsulate the fuck out of the <code>Dude</Tcode> class.
+
# Encapsulate the fuck out of the <code>Dude</code> class.
 
# Increase the number of <code>Poo</code> objects from 3 to 9.
 
# Increase the number of <code>Poo</code> objects from 3 to 9.
  
The solution is given in a future video.
+
The solution is given in [https://youtu.be/8Lb-E4g0lpc this video].
  
 
== Downloads ==
 
== Downloads ==
  
I'll put the starting code here when I get access to it (away from home at the moment). If you have the solution from the Tutorial 11 homework you can use it instead.
+
* The starting code for Tutorial 12 is [https://www.planetchili.net/downloads/T12-Poo.zip here].
 +
* [https://planetchili.net/downloads/apworks/12/Beginner%20Tutorial%2012%20Code.zip Tutorial 12 Code]
 +
* [https://planetchili.net/downloads/apworks/12/Beginner%20Tutorial%2012%20HW%20Code.zip Tutorial 12 Homework Solution Code]
  
 
== See also ==
 
== See also ==
 
* [https://www.patreon.com/planetchili Planet Chili Patreon]
 
* [https://www.patreon.com/planetchili Planet Chili Patreon]
* [[Beginner C++ Game Programming Tutorial 13|Next in series (Tutorial 12)]]
+
* [[Beginner C++ Game Programming Tutorial 13|Next in series (Tutorial 13)]]
 
* [[Beginner C++ Game Programming Series]]
 
* [[Beginner C++ Game Programming Series]]

Latest revision as of 13:20, 5 May 2022

Here we learn about the concept of encapsulation (ask your mom where she keeps the Vicodin!), which is the main principle behind object oriented programming (so listen the fuck up eh?). We also learn how to construct shit, and how to make our shit private.

Important Note

Visual Studio has a <cool feature> wherein when you use "quick actions... -> move definition location" on a constructor, it adds a goddamn inline keyword which fucks the whole goddamn works up! D:< This is fixed in the homework solution, but if you are attempting the homework before peeking (as you should be), then this could fuck you up royally. Keep it in mind.

Concepts Taught

  • Encapsulation and data hiding
  • How to create a constructor
  • How do initialize embedded objects (class initializer list)
  • How to control member access (private keyword)

Encapsulation

This page has some interesting discussion on why we bother with all this encapsulation bullshit.

Video Timestamp Index

  • Intro 0:00
  • Encapsulation: Difference between public and private data members 0:55
  • Poo class: Making member data private 2:43
  • Important note on "Getters" and "Setters" 5:00
  • Advantages of private member data with a getter and setter, as opposed to just public member data 7:07
  • Constructors: setting values during object initialization 9:30
  • Class initializer list: Initializing embedded objects (Poo objects inside a Game object) 12:34
  • Class initializer list order must correspond to the order of data member declaraion 17:10
  • Visual Studio tricks: Quick actions -> Move definition location, but with a little brainfucky surprize you will learn about very soon 19:59
  • Reasons to properly encapsulate class member data 20:52
  • Homework 30:10

Homework

  1. Encapsulate the fuck out of the Dude class.
  2. Increase the number of Poo objects from 3 to 9.

The solution is given in this video.

Downloads

See also