06:16 Generic RPG Class Information - Character cognitive views of learning Definition | |
Now, lets start to slowely build up our individual classes with there subclass members. Starting off with the inventory class, it has 1 child class of conatainers, this class will be used with 2 direct constructs and 1 pointerlist.Cognitive views of learning in the end, we will have 5 total conatiner objects for our bags, 1 for our purse and 1 for our tradeskills, leaving 7 total container objects that get created.Cognitive views of learning The uniquenes of the code is that 2 are directly created container objects (purse and tradeskills) and 5 are held in the pointer list, so the cleanup is different between the 2 directly created container objects vs the 5 that are held in the pointer list.Cognitive views of learning when we destroy the objects in the pointer list, we do not see the destructor purge of each individual object destroyed in the list, but we do see the 2 destructor calls for the ones directly created.Cognitive views of learning What you should understand from this, is that we have classes nested in classes which is created from another class, so we are now 3 classes deep.Cognitive views of learning you can have a virtual endless level of classes. I am also starting to move the destructor into a virtual destructor which we will get into later for the difference between virtual and non-virtual.Cognitive views of learning These include primary, secondary, shield, ammo, and ranged classes. After we create the classes just like we did for all the other classes, we then update the weapons.Inc file to include the #include to point to each of the new classes inc files, our project is expanded to include there src files in the project and lastly, we update our weapons class to include a new instance of each of the weapon classes that are new.Cognitive views of learning When weapons gets instansiated, it then in turn, instansiates a new instance of each of the sub classes for primary, secondary, shield, ammo, and ranged.Cognitive views of learning now, I know what you are thinking, a shield isn't a weapon, well, it takes damage and can deal damage, the only difference between a shield and a sword is its size.Cognitive views of learning ever get hit over the head with a shield with blunt force? Ammo goes along with the ranged weapon, so why is it not attached to the ranged? Why not in deed, there are two different ways to handle ammo, in my diagram, ammo is a subclass of weapon, this allows you to have ammo individualy without a weaopn, or you can have ranged inherit ammo.Cognitive views of learning in the code, just for fun, I have ranged inherit ammo, and since ammo is its own class, we can instansiate it by itself later if we need to.Cognitive views of learning We are now over the half way point of building the full blown class skeleton. Today, we have added to the project the entire tradeskill class, this means our character class now contains the skeleton structure for both weapon crafting and armor crafting.Cognitive views of learning each of those two classes are member objects to the tradeskills, these two in turn have there own child objects which are the different items that can get crafted.Cognitive views of learning one thing to note that I have not gotten into yet, and once I get done with the full blown class skeleton model in code for you, will be the base classes that go along with each and every linked set of classes.Cognitive views of learning Just like the character inheriting its base class, every blocked class in the diagram (as in, contained in a block via the diagram) would infact have base classes that are helper classes to all of the contained objects, where they would all (within there block) inherit from that base.Cognitive views of learning what would be in it? Could you envision some items that would be in common by looking at each blocked class set? Think about this for a while.Cognitive views of learning maybe you can go ahead and write your own base class and attach it to each child class within a superclass object. | |
|
Total comments: 0 | |