Object-Oriented Programming Concepts: Classes, Constructors, and Inheritance

c basics part2 n.w
1 / 19
Embed
Share

Explore the fundamentals of object-oriented programming with topics like classes, constructors, and inheritance in C#. Learn how to create objects, utilize constructors with and without arguments, implement functions within classes, and understand the concept of inheritance for code reusability and extensibility.

  • OOP Concepts
  • Classes
  • Constructors
  • Inheritance
  • C#
  • Programming

Uploaded on | 2 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. C# BASICS PART2 These slides are designed for Game Design Class Science and Culture University By Alireza Seddighi. Email: alirezaseddighi@live.com

  2. COROUTINES For programming a Delayed function IEnumerator functionName(){ yield return newWaitForSeconds (amount of wait f); print ( print"); } IEnumerator printsthofterawhile(){ yield return newWaitForSeconds (2f); print ("Wait for 2 Sec"); } How to call ???

  3. COROUTINES 2 ways to call coroutines: First: StartCoroutine (FunctionName()); StartCoroutine (printsthofterawhile()); Secend: StartCoroutine (" FunctionName "); StopCoroutine (" FunctionName "); What s the Deference???

  4. CLASSES Classes are blueprint for creating objects public class Player { } Constructs: used to initialized the variables public Player(){ health = 150; power = 100; name = "prince"; Debug.Log ("player instantiate, Health = " + health + " Power = " + power + " Name = " + name); }

  5. OBJECTS Creating an object From the class = call the constructor Player prince = new Player (); Note: we call the constructor

  6. CONSTRUCTOR WITH ARGUMENT public Player (int health, int power, string name){ // this. is referred to the current class this.health = health; this.power = power; this.name = name; Debug.Log ("player instantiate, Health = " + health + " Power = " + power + " Name = " + name); }

  7. USING FUNCTIONS IN CLASS public Player(int health, int power, string name){ // this. is referred to the current class this.health = health; this.power = power; this.name = name; Debug.Log ("player instantiate, Health = " + health + " Powe r = " + power + " Name = " + name); } How to call the function: prince.playerinfo ();

  8. INHERITANCE Is going to inherit every function variable from the parent class

  9. INHERITANCE OVERRIDE FUNCTION Override a function in the child class How to declare such function in parent class? How to override function in child class?

  10. GET COMPONENT First Step is to attach the component to the game object By selecting the game object and Add Component

  11. GET COMPONENT Second Step is to referenced that component in the script 1. create a variable 2. use the GetComponent to referenced 3. and then use the available functions

  12. ENCAPSULATION Is used for accessing private variable Need to declare Get and Set function Get function is to return the predefined value of private variable And Set function is to Set a proper value to the private variable

  13. ENCAPSULATION

  14. DELEGATES Static variables Using the variable that define in a class without creating any object from that class

  15. ENUMERATIONS A list of things How to make Enumeration list ?

  16. ENUMERATIONS How to use Enumeration list ?

  17. ENUMERATIONS How to use Enumeration list ?

  18. ENUMERATIONS

  19. TWO DIMENSIONAL ARRAYS

Related


More Related Content