Showing posts with label notes. Show all posts
Showing posts with label notes. Show all posts

Monday, March 23, 2020

[C#] Derived and Base Class, sealed keyword

In C#, you can  inherit fields and methods from another class. It’s inheritance..

  1. Derived Class : is child class that inherits from another class.
  2. Base Class : is the parent class which the class being inherited from.

We use the : symbol to inherit from a class.
class Person { // base class
  public string type = "Person";
  public void say() {
    Console.WriteLine("Hello");
  }
}

class Student : Person { // derived class
  public string type = "Student";
  public int studentId = 1;
}
class Program {
  static void Main(string[] args)  {
    Student student = new Student();
    student.say();
    Console.WriteLine(student.type +
         " " + student.studentId);
  }
}

Result :
Hello
Student 1

sealed Keyword

If you don’t want others class inherit from a class, you can use sealed keyword
sealed class Person {
  public string type = "Person";
  public void say() {
    Console.WriteLine("Hello");
  }
}

class Student : Person {
  ...
}
You would get error message that 'Student' : cannot derive from sealed type.

[Mathematics] Type and notation of interval

In mathematics, a (real) interval is a set of real numbers lying between two numbers, we used to see something like this:
x < 4
it means x is smaller than 4.
-2 ≤ x ≤ 3
and this mean x is greater or equal to -2 and less than or equal to 3.

Types of the interval :


  • close-interval
  • open-interval, doesn't not 
  • half-interval
  • infinite interval 
Close interval
we use the notation [ or ] to represent the closed side
[-2,3] means -2 ≤ x ≤ 3

Open interval
we use the notation ( or ) to represent the open side
(-16,-9) means -16 < x < -9

Half interval
you would have both open side and close side in the interval.
[-7,2) means -7 ≤ x < 2

Infinite interval
For infinite interval, the ∞ sign is used.
(1,∞ ) mean x>1

More usage and example:

Remarks

Sometimes we use the union notation ⋃ to join two interval"
(-∞,1)⋃[∞,2)

(-∞,1) means interval x<1 and [∞,2) means interval x≥ 2.
(-∞,1)⋃(∞,2) is equivalent to x<1 or x≥ 2.

and intersect notation ∩ to get the collection of values in both interval:
(-∞,2)∩[1,3)

(-∞,2) means interval x<2 and [1,3) means interval 1≤x<3.
(-∞,2)∩[1,3) is equivalent to 1≤x<2.


Reference:

Monday, March 2, 2020

[Mathematics] Symmetric with respect to axis

There are 3 major type of symmetric about an axis:

  1. symmetric with respect to the x-axis
  2. symmetric with respect to the y-axis
  3. symmetric with respect to the the origin







The advantage to know an equation is symmetric is you can use the result to predict behavior on the other side.

In addition to using graph to find out the function is symmetric with respect to axis, we can also use check it symmetric alone axis by replacing points.

Let use this function as example:
y2=x-1

Examine symmetric about y-axis
We can replace (x,y) with (-x,y) to examine symmetric about y-axis
By replacing x to -x, we get y2=(-x)-1 from y=x-1
y2=-x-1
Since y2=-x-1 is not same to y2=x-1, the graph would not symmetric about y-axis.


Examine symmetric about x-axis
We can replace (x,y) with (x,-y) to examine symmetric about x-axis
By replacing y to -y, we get -y2=x-1 from y2=x-1
(-y)2=x-1
 (y)2=x-1
Since (-y)2=x-1 is same to y2=x-1, the graph is symmetric about x-axis.


Examine symmetric about origin
We can replace (x,y) with (-x,-y) to examine symmetric about origin
By replacing y to -y, we get (-y)2=(-x)-1 from y2=x-1
(-y)2=(-x)-1
    y2=-x-1
Since (-y)2=(-x)-1 is not same to y2=x-1, the graph is not symmetric about origin.

Finally, let take a peek about how y2=x-1 look like in graph: