{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c7c45369",
   "metadata": {},
   "source": [
    "# Chapter Review\n",
    "\n",
    "- Follow the lab assignment format to prepare this assignment.\n",
    "- Create a project folder called `Ch10Classes` to include the code for this\n",
    "  project.\n",
    "- Question 6~10 require code and execution screenshots when applicable.\n",
    "\n",
    "01. What is the keyword used to create an instance of a class?\n",
    "\n",
    "02. Can you create an object from a class resides in another file?\n",
    "\n",
    "03. What is the purpose of a constructor?\n",
    "\n",
    "04. Describe the process of implementing inheritance in polymorphism in steps.\n",
    "\n",
    "05. If you want to use an instance variable (field) in a method, should you declare\n",
    "    that instance variable in the method? Why?\n",
    "\n",
    "06. How do you create an instance of the following class?\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "    class DoMath\n",
    "    {\n",
    "        public int Sum(int num1, int num2)\n",
    "        {\n",
    "            var total = num1 + num2;\n",
    "            return total;\n",
    "        }\n",
    "    }\n"
   ],
   "id": "4bb3baed"
  },
  {
   "cell_type": "markdown",
   "id": "8eead56b",
   "metadata": {},
   "source": [
    "\n",
    "07. How do you use the following class to use the Sum method for summing up two integers? Prepare\n",
    "    your code in your Program.cs Main method.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "    static class SomeMath\n",
    "    {\n",
    "        public static int Sum(int a, int b)\n",
    "        {\n",
    "            return a + b;\n",
    "        }\n",
    "    }\n"
   ],
   "id": "568c0948"
  },
  {
   "cell_type": "markdown",
   "id": "dfc30ccc",
   "metadata": {},
   "source": [
    "\n",
    "08. Define a `Math` class, when **instantiated**, offer the functionality of two\n",
    "    summing methods with the same name Sum that would take 2 and 3 arguments,\n",
    "    respectively, and sum them up and return the results.\n",
    "\n",
    "09. Change the preceding code to allow the passing of an unspecified number of integer arguments\n",
    "    (see, e.g., <https://stackoverflow.com/questions/1996426/pass-multiple-optional-parameters-to-a-c-sharp-function>).\n",
    "    Save the file in the project folder,call it SumManyArgs.cs and use SumManyArgs as the class name.\n",
    "\n",
    "10. Does the following code define a public or private class? Add an access modifier without\n",
    "    changing the existing accessibility level. Show your changed code and explain why.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "    class Customer\n",
    "    {\n",
    "        // Fields, properties, methods and events go here...\n",
    "    }\n"
   ],
   "id": "e9fac46b"
  },
  {
   "cell_type": "markdown",
   "id": "59460f4f",
   "metadata": {},
   "source": [
    "\n",
    "% #.  What does the ``this`` keyword do in the context of this chapter?\n",
    "\n",
    "% #.  If we want users to be able to see the value of a private instance variable\n",
    "\n",
    "% from outside of the class, how do we do it?\n",
    "\n",
    "% #.  What is the general name of the category of public methods whose sole purpose\n",
    "\n",
    "% is to set a part of instance state to a new specified value?\n",
    "\n",
    "% #.  If you do not explicitly assign a value to an instance variable in a\n",
    "\n",
    "% constructor, does the instance variable have a value?\n",
    "\n",
    "% #.  What is the general name of the category of methods that return\n",
    "\n",
    "% instance state values?\n",
    "\n",
    "% #.  Instance variables are usually visible from inside instance methods for\n",
    "\n",
    "% the class.  What is the exception?  In the exceptional case, what is\n",
    "\n",
    "% the workaround to allow access to the instance variable?\n",
    "\n",
    "% #.  Sometimes you need to refer explicitly to the current object.  How\n",
    "\n",
    "% do you do it?\n",
    "\n",
    "% #.  What is the return type for a setter method?\n",
    "\n",
    "% #.  If a class has one or more setter methods, is the object type\n",
    "\n",
    "% immutable?\n",
    "\n",
    "% #.  Where in a class are instance variables declared?\n",
    "\n",
    "% #.  For most instance variables, what is the modifier used that does not\n",
    "\n",
    "% appear at the beginning of a local variable declaration?\n",
    "\n",
    "% #.  What is the lifetime of an instance variable:\n",
    "\n",
    "% When does it come into existence, and how long does it last?\n",
    "\n",
    "% #.  Why do we generally make an instance variable ``private``?\n",
    "\n",
    "% #.  In what code can an instance variable be seen and used?\n",
    "\n",
    "% #.  Must instance variables and methods always be preceded by\n",
    "\n",
    "% an explicit object reference and ``.``?\n",
    "\n",
    "% #.  Can we refer to an instance variable in a part of the code\n",
    "\n",
    "% where there is no current object?\n",
    "\n",
    "% #.  In what kind of method in a class definition are instance variables never\n",
    "\n",
    "% accessible?\n",
    "\n",
    "% #.  A method with what signature allows you to control how the string\n",
    "\n",
    "% concatenation operate (``+``) generates a string from the object?\n",
    "\n",
    "% #.  If you write an override the ``ToString`` method in a class, should the method\n",
    "\n",
    "% print the string?   If not, what should it do with the resulting string?\n",
    "\n",
    "% #.  Can aliased objects cause problems when created for an immutable object?\n",
    "\n",
    "% Mutable object?\n",
    "\n",
    "% #.  In a class with instance methods you can always design the class so variables\n",
    "\n",
    "% are instance variables and not local variables.  When should you\n",
    "\n",
    "% use local variables instead?\n",
    "\n",
    "% #. If an instance method has a formal parameter of the same type as the\n",
    "\n",
    "% class being defined,\n",
    "\n",
    "% can you refer to a private instance variable in the parameter object?\n",
    "\n",
    "% May you change it?\n",
    "\n",
    "% How do you distinguish an instance variable for the current object from the\n",
    "\n",
    "% corresponding instance variable for the parameter object?"
   ]
  }
 ],
 "metadata": {
  "jupytext": {
   "cell_metadata_filter": "-all",
   "main_language": "python",
   "notebook_metadata_filter": "-all"
  },
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "name": "csharp"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
