Angry Birds

Summery Constractor, Destructor, and Polymorphism

Label:

Summary Constractor n Destructor

- A constructor is used to initialize the members of the class.
- There are two types of constructors, instance constructors and static constructors.
- Instance constructors are used to initialize data members of the class.
- Static constructors are used to initialize the static variables of a class.
- Destructors are used to release the instance of a class from memory.
- Garbage collection is a process that automatically frees the memory of objects that are no
more in use.
- Objects get destroyed: It does not specify when the object shall be destroyed.
- Only unused objects are destroyed: An object is never destroyed if it holds the
reference of another object.
- The Finalize() destructor is a special method that is called from the class to which it
belongs or from the derived classes. The Finalize() destructor is called after the last
reference to an object is released from the memory.
- The Dispose() method is called to release a resource, such as a database connection, as
soon as the object using such a resource is no longer in use.


Summary Polymorphism

- Static Polymorphism refers to an entity.
- Function Overloading allows using the same name for two or more function.
- The type, sequence, or number of parameters for a function is called the function signature.
- Operator overloading allows user defined types such as structures and classes.
- Dynamic Polymorphism function execution is made at runtime and it compared to static polymorphism.
- Abstract classes consist of abstract class numbers.
- Virtual function is appear to be present in some parts of the program.

Triangle's Formula Using Java

Label: ,

Now, I wanna tell you how to find the value of triangle side. Hmm.. Maybe I'm not good in math, but I always try to find it as long as I can. So, if you find any wrong in my syntax, please put your comment.
Hehe.. Here is the syntax... Lets check it out!


package chacam.main;

public class SisiSegitigaSembarang
{
    public static void main(String[] args)
    {
        int a,b,c;
        double degreeA, degreeB, degreeC;

        a = 8;

        degreeA = 65;
        degreeB = 95;
        degreeC = 20;

        b = (int) ((a) * Math.sin(degreeB) / (Math.sin(degreeA)));

        System.out.println("Nilai sisi b = "+b);

        c = (int) ((b)*Math.sin(degreeC)/(Math.sin(degreeB)));

        System.out.println("Nilai sisi c = "+c);

    }
}



A Simple Calculator Using C#

Label: ,

This time, I wanna share the the syntax to make a simple calculator using C#.
Here it is..!



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Calculator
{
    class Calculating
    {
        int Number1, Number2;
        char option;
        int Result;
        public void Number()
        {
            Console.WriteLine("Enter the First number");
            Number1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter the second number");
            Number2 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Main Menu");
            Console.WriteLine("1.Addition");
            Console.WriteLine("2.Subtraction");
            Console.WriteLine("3.Multiplication");
            Console.WriteLine("4.Division");
            Console.WriteLine("Enter the Operation you want to perform");
            option = Convert.ToChar(Console.ReadLine());
            switch (option)
            {
                case '1':
                    Result = Number1 + Number2;
                    Console.WriteLine("The result of addition is:{0}", Result);
                    break;
                case '2':
                    Result = Number1 - Number2;
                    Console.WriteLine("The result of subtraction is:{0}", Result);
                    break;
                case '3':
                    Result = Number1 * Number2;
                    Console.WriteLine("The result of multiplication is:{0}", Result);
                    break;
                case '4':
                    Result = Number1 / Number2;
                    Console.WriteLine("The result of division is:{0}", Result);
                    break;
                default:
                    Console.WriteLine("Invalid Option");
                    break;
            }
            Console.ReadLine();
        }
    }
}

class ClassMain
{
    static void Main(string[] args)
    {
        Calculator.Calculating obj = new Calculator.Calculating();
        obj.Number();
    }
}