Ejemplo n.º 1
0
 ConstantMessage objconst;//object creation
 ///<summary>
 ///Method Name:DataTypeConv
 /// Description://convert double to integer
 /// Author:bhumi
 /// Created On:21/5/2015
 /// </summary>
 public void DataTypeConv()
 {
     objconst = new ConstantMessage();
     try
     {
         //variables
         double double_number, integer_round;
         int    integer_cast, integer_Manual;
         Console.WriteLine(objconst.strdoubleInt);
         //Get the number from user
         Console.WriteLine(objconst.strdoubleno);
         double_number = Convert.ToDouble(Console.ReadLine());
         //Printing integer part of double number
         //Casting
         Console.WriteLine(objconst.strcast);
         integer_cast = (int)double_number;
         Console.WriteLine(integer_cast);
         Console.WriteLine(objconst.strround);
         //round off
         integer_round = Math.Round(double_number);
         Console.WriteLine(integer_round);
         //Manually
         Console.WriteLine(objconst.strmanual);
         integer_Manual = Convert.ToInt32(double_number);
         Console.WriteLine(integer_Manual);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 ///Method Name:Getdate_Struct
 /// Description://Create Structure to store date
 /// Author:bhumi
 /// Created On:26/5/2015
 /// </summary>
 public void Getdate_Struct()
 {
     try
     {
         objstructdate = new Struct_Date();
         objconst      = new ConstantMessage();
         Console.WriteLine(objconst.strdate);
         dt2 = Convert.ToInt32(Console.ReadLine());
         Console.WriteLine(objconst.strmonth);
         mn2 = Convert.ToInt32(Console.ReadLine());
         Console.WriteLine(objconst.stryear);
         yr2 = Convert.ToInt32(Console.ReadLine());
         objstructdate.Date  = dt2;
         objstructdate.Month = mn2;
         objstructdate.Year  = yr2;
         DateTime dateTime = new DateTime(yr2, mn2, dt2);
         arraylistdate.Add(dateTime);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine(objconst.strinvalid);
         Getdate_Struct();
     }
 }
Ejemplo n.º 3
0
 ///<summary>
 ///Method Name:Property_Method
 /// Description://Method to set the values of property
 /// Author:bhumi
 /// Created On:26/5/2015
 /// </summary>
 public void Property_Method()
 {
     try
     {
         objconst = new ConstantMessage();
         Console.WriteLine(objconst.strsalutation);
         slt = Console.ReadLine();   // set Value of property
         Console.WriteLine(objconst.strname);
         nam = Console.ReadLine();   //set Value of property
         Console.WriteLine(objconst.strMaritalstat);
         MarSt = Console.ReadLine(); //set Value of property
         Console.WriteLine(objconst.strgender);
         gendr = Console.ReadLine(); //set Value of property
         Console.WriteLine(objconst.straddress);
         adr = Console.ReadLine();   //set Value of property
         Console.WriteLine(objconst.strQualification);
         qu = Console.ReadLine();    //set Value of property
         Console.WriteLine(objconst.strLanguage);
         ln = Console.ReadLine();    //set Value of property
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 4
0
 ConstantMessage objconst; //object creation
 /// <summary>
 ///Method Name:FindVowel
 /// Description://check that entered character is vowel or not
 /// Author:bhumi
 /// Created On:21/5/2015
 /// </summary>
 public void FindVowel()
 {
     try
     {
         objconst = new ConstantMessage();
         Console.WriteLine(objconst.strChar);
         char ch = Convert.ToChar(Console.ReadLine());
         if (ch == 'A' || ch == 'a' || ch == 'E' || ch == 'e' || ch == 'I' || ch == 'i' || ch == 'O' || ch == 'o' || ch == 'U' || ch == 'u')
         {
             Console.WriteLine(objconst.strVowel);
         }
         else
         {
             Console.WriteLine(objconst.strconsonant);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 5
0
 ConstantMessage objconst;//object creation
 public void WriteToFile()
 {
     try
     {
         objconst = new ConstantMessage();
         int counter = 0;
         //Create the file
         string     path = @"D:\MyFile.txt", line;//Specific Path
         TextWriter tw = new StreamWriter(path);
         //5 lines will be written in file
         while (counter < 5)
         {
             Console.WriteLine(objconst.strfilewrite);
             line = Console.ReadLine();
             tw.WriteLine(line);
             counter++;
         }
         tw.Close();
         System.Console.WriteLine("There were {0} lines.", counter);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 6
0
 ConstantMessage objconst;//object creation
 ///<summary>
 ///Method Name:Trasform
 /// Description://Transformation operation on array
 /// </summary>
 public void Trasform()
 {
     objconst = new ConstantMessage();
     try
     {
         //Defining Array
         int[,] twoD_array = new int[4, 7];
         int row_size, colm_size;
         Console.WriteLine(objconst.strarraytransform);
         //user defined rows
         Console.WriteLine(objconst.strrow);
         row_size = Convert.ToInt32(Console.ReadLine());
         //user defined columns
         Console.WriteLine(objconst.strcolumn);
         colm_size = Convert.ToInt32(Console.ReadLine());
         //Insert the elements in array
         Console.WriteLine(objconst.strdatainsert);
         for (int i = 0; i < row_size; i++)
         {
             for (int j = 0; j < colm_size; j++)
             {
                 twoD_array[i, j] = Convert.ToInt32(Console.ReadLine());
             }
             Console.WriteLine("==============================================");
         }
         Console.WriteLine(objconst.strmainarray);
         //print the original Array
         for (int i = 0; i < row_size; i++)
         {
             for (int j = 0; j < colm_size; j++)
             {
                 Console.Write(twoD_array[i, j] + "\t");
             }
             Console.WriteLine("\n");
         }
         Console.WriteLine("==============================================");
         Console.WriteLine(objconst.strtransform_array);
         //print the Transformed Array
         for (int i = 0; i < colm_size; i++)
         {
             for (int j = 0; j < row_size; j++)
             {
                 Console.Write(twoD_array[j, i] + "\t");
             }
             Console.WriteLine("\n");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 7
0
 ConstantMessage objconst;//object creation
 ///<summary>
 ///Method Name:BubbleSort
 /// Description:Sorting array using bubblesort
 /// Author:bhumi
 /// Created On:21/5/2015
 /// </summary>
 public void BubbleSort()
 {
     objconst = new ConstantMessage();
     try
     {
         int   Arry_Size, temp;
         int[] array;
         //Input from the user
         Console.WriteLine(objconst.strarraysize);
         Arry_Size = Convert.ToInt32(Console.ReadLine());
         Console.WriteLine(objconst.strinput);
         array = new int[Arry_Size];
         for (int i = 0; i < array.Length; i++)
         {
             array[i] = Convert.ToInt32(Console.ReadLine());
         }
         Console.WriteLine("==============================================");
         //Display the Array
         Console.WriteLine(objconst.strarrayelement);
         for (int i = 0; i < array.Length; i++)
         {
             Console.WriteLine(array[i]);
         }
         Console.WriteLine("==============================================");
         //Bubble Sort
         for (int i = 0; i < array.Length; i++)
         {
             for (int j = 0; j < array.Length - 1; j++)
             {
                 if (array[j] > array[j + 1])
                 {
                     temp         = array[j + 1];
                     array[j + 1] = array[j];
                     array[j]     = temp;
                 }
             }
         }
         //print the sorted array
         Console.WriteLine(objconst.strsort);
         foreach (int a in array)
         {
             Console.Write(a + " ");
         }
         Console.WriteLine();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 8
0
 ConstantMessage objconst;//object creation
 ///Method Name:CountFunction
 /// Description://Searching operation from array
 /// Author:bhumi
 /// Created On:21/5/2015
 /// </summary>
 public void CountFunction()
 {
     try
     {
         int   array_size, flag = 0; // flag variable
         int   count = 0;            //count variable;
         int[] array1;
         objconst = new ConstantMessage();
         Console.WriteLine(objconst.strarraysize);
         array_size = Convert.ToInt32(Console.ReadLine());
         array1     = new int[array_size];
         Console.WriteLine(objconst.strinputbetween);
         for (int i = 0; i < array1.Length; i++)
         {
             array1[i] = Convert.ToInt32(Console.ReadLine());
         }
         Console.WriteLine("==============================================");
         //Serching number from arra1
         Console.WriteLine(objconst.strelement);
         int num = Convert.ToInt32(Console.ReadLine());
         for (int i = 0; i < array1.Length; i++)
         {
             if (array1[i] == num)
             {
                 flag = 1;//reset the flag
                 count++;
             }
         }
         if (flag == 1)
         {
             Console.WriteLine(num + objconst.strexist);
         }
         else
         {
             Console.WriteLine(num + objconst.strnotexist);
         }
         Console.WriteLine("==============================================");
         //check the occurrence of number in array
         if (count > 0)
         {
             Console.WriteLine(num + "\tappear\t" + count + "\tTimes in Array");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 9
0
        ConstantMessage objconst; //object creation
        /// <summary>
        ///Method Name:DateSort
        /// Description://Create Structure & sort the dates
        /// Author:bhumi
        /// Created On:25/5/2015
        /// </summary>
        public void DateSort()
        {
            try
            {
                objconst = new ConstantMessage();
                //Pass by value
                Console.WriteLine(objconst.strdate);
                dt1 = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(objconst.strmonth);
                mn1 = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(objconst.stryear);
                yr1 = Convert.ToInt32(Console.ReadLine());

                Str_Date structdate;
                structdate.Dt = dt1;
                structdate.mn = mn1;
                structdate.yr = yr1;
                SetDate(structdate);

                //Pass by reference
                Console.WriteLine(objconst.strdate);
                dt2 = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(objconst.strmonth);
                mn2 = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(objconst.stryear);
                yr2 = Convert.ToInt32(Console.ReadLine());
                SetDate(ref structdate);
                input1 = dt1 + "-" + mn1 + "-" + yr1;
                input2 = dt2 + "-" + mn2 + "-" + yr2;
                //Original dates
                if (DateTime.TryParse(input1, out datetime1) && DateTime.TryParse(input2, out datetime2))
                {
                    Console.WriteLine(objconst.stractualdate);
                    Console.WriteLine(input1);
                    Console.WriteLine(input2);
                    //SORT the DATES
                    Console.WriteLine(objconst.strsortdate);
                    List <string> dates = new List <string>()
                    {
                        dt1 + "-" + mn1 + "-" + yr1, dt2 + "-" + mn2 + "-" + yr2
                    };
                    foreach (var date in dates.OrderBy(x => x))
                    {
                        Console.WriteLine(date);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 10
0
 ///<summary>
 ///Method Name:Load
 /// Description://Methods of customer Class
 /// Author:bhumi
 /// Created On:21/5/2015
 /// </summary>
 public void Load()
 {
     try
     {
         Console.WriteLine(objconst.strload);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 11
0
 public void Save_entity()
 {
     try
     {
         Console.WriteLine(objconst.strsave);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 12
0
 public void Validate()
 {
     try
     {
         Console.WriteLine(objconst.strvalidate);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 13
0
        ///<summary>
        ///Method Name:Exit
        /// Description://User want to terminate console application
        /// Author:bhumi
        /// Created On:21/5/2015
        /// </summary>
        public void Exit()
        {
            ConstantMessage objconst = new ConstantMessage();//object creation

            Console.WriteLine(objconst.strContinue);
            string end = Console.ReadLine();

            if (end == "Y" || end == "y")
            {
            }
            else
            {
                Environment.Exit(0);
            }
        }
Ejemplo n.º 14
0
 ConstantMessage objconst;//object creation
 /// <summary>
 ///MethodName:CountChar
 /// Description://count uppercase lowercase & digits from input string
 /// Author:bhumi
 /// Created On:21/5/2015
 /// </summary>
 public void CountChar()
 {
     try
     {
         objconst = new ConstantMessage();
         //Declaring integers to be used
         int countedWords = 0;
         int cap_count    = 0;
         int lower_count  = 0;
         int digit        = 0;
         Console.WriteLine(objconst.strstring);
         string inputString = Console.ReadLine();
         //counts words
         countedWords = inputString.Split(' ').Length;
         foreach (char c in inputString)
         {
             //if is upper case add to cap_count
             if (Char.IsUpper(c))
             {
                 cap_count++;
             }
             //if char is a punctuation or white space ignore it else
             // add as lower case
             else if (!char.IsPunctuation(c) && !char.IsWhiteSpace(c) && !char.IsDigit(c))
             {
                 lower_count++;
             }
             //find the digits
             else if (Char.IsDigit(c))
             {
                 digit++;
             }
         }
         //display results.
         Console.WriteLine(objconst.strletter + (cap_count + lower_count));
         Console.WriteLine(objconst.strupper + cap_count);
         Console.WriteLine(objconst.strlower + lower_count);
         Console.WriteLine(objconst.strdigit + digit);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 15
0
 ConstantMessage objconst;//object creation
 /// <summary>
 ///Method Name:SearchFunction
 /// Description://Searching operation from array
 /// Author:bhumi
 /// Created On:21/5/2015
 /// </summary>
 public void SearchFunction()
 {
     try
     {
         objconst = new ConstantMessage();
         int   array_size, num;
         int   flag = 0;// flag variable
         int[] array1;
         // Array
         //Input from the user for array size
         Console.WriteLine(objconst.strarraysize);
         array_size = Convert.ToInt32(Console.ReadLine());
         array1     = new int[array_size];
         Console.WriteLine(objconst.strinput);
         for (int i = 0; i < array1.Length; i++)
         {
             array1[i] = Convert.ToInt32(Console.ReadLine());
         }
         Console.WriteLine("==============================================");
         //Serching number from arra1
         Console.WriteLine(objconst.strelement);
         num = Convert.ToInt32(Console.ReadLine());
         for (int i = 0; i < array1.Length; i++)
         {
             if (array1[i] == num)
             {
                 flag = 1;//reset the flag
             }
         }
         if (flag == 1)
         {
             Console.WriteLine(num + objconst.strexist);
         }
         else
         {
             Console.WriteLine(num + objconst.strnotexist);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 16
0
 public void GetFees()
 {
     objconst = new ConstantMessage();
     try
     {
         Console.WriteLine("Enter " + objconst.strfees);
         fees = Convert.ToDouble(Console.ReadLine());
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 17
0
 ConstantMessage objconst;//object creation
 //Write code to open the Notepad application in Windows
 ///<summary>
 ///Method Name:OpenFile
 /// Description://open notepade file using console application
 /// Author:bhumi
 /// Created On:21/5/2015
 /// </summary>
 public void OpenFile()
 {
     try
     {
         string filenm;
         objconst = new ConstantMessage();
         //Get the file name from use
         Console.WriteLine(objconst.strfilename);
         filenm = Console.ReadLine();
         System.Diagnostics.Process.Start("notepad.exe", "D://" + filenm + ".txt");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 18
0
 ConstantMessage objconst;//object creation
 /// <summary>
 ///MethodName:ArrayReverse
 /// Description://Find the reverse form of entered Array
 /// Author:bhumi
 /// Created On:21/5/2015
 /// </summary>
 public void ArrayReverse()
 {
     try
     {
         int      Array_Size;
         string[] array1;
         objconst = new ConstantMessage();
         Console.WriteLine(objconst.strarraysize);
         Array_Size = Convert.ToInt32(Console.ReadLine());
         //Input from the user
         Console.WriteLine(objconst.strarray);
         array1 = new string[Array_Size];
         for (int i = 0; i < array1.Length; i++)
         {
             array1[i] = Console.ReadLine();
         }
         Console.WriteLine("==============================================");
         //Display the Array
         Console.WriteLine(objconst.strarrayelement);
         for (int i = 0; i < array1.Length; i++)
         {
             Console.WriteLine(array1[i]);
         }
         Console.WriteLine("==============================================");
         //Array in Reverse form
         Console.WriteLine(objconst.strrev);
         for (int i = array1.Length - 1; i >= 0; i--)
         {
             Console.WriteLine(array1[i]);
         }
         Console.ReadKey();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 19
0
 ConstantMessage objconst;//object creation
 //Modify the Reverse code so the program will print the numbers sorted in ascending order.
 /// <summary>
 ///Method Name:ArraySort
 /// Description://Array reverse & sort Operation
 /// Author:bhumi
 /// Created On:21/5/2015
 /// </summary>
 public void ArraySort()
 {
     try
     {
         int   Array_Size;
         int[] array1;
         objconst = new ConstantMessage();
         //Input from the user
         Console.WriteLine(objconst.strarraysize);
         Array_Size = Convert.ToInt32(Console.ReadLine());
         Console.WriteLine(objconst.strinput);
         array1 = new int[Array_Size];
         for (int i = 0; i < array1.Length; i++)
         {
             array1[i] = Convert.ToInt32(Console.ReadLine());
         }
         Console.WriteLine("==============================================");
         //Display the Array
         Console.WriteLine(objconst.strarrayelement);
         for (int i = 0; i < array1.Length; i++)
         {
             Console.WriteLine(array1[i]);
         }
         Console.WriteLine("==============================================");
         //Array sorted in ascending order
         Console.WriteLine(objconst.strascend);
         Array.Sort(array1);
         for (int i = 0; i < array1.Length; i++)
         {
             Console.WriteLine(array1[i]);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 20
0
 ConstantMessage objconst;//object creation
 //Print out the currently logged in Windows username, home directory and the OS name.
 ///<summary>
 ///Method Name:GetDetails
 /// Description://Details about Username,home directory & os Name
 /// Author:bhumi
 /// Created On:21/5/2015
 /// </summary>
 public void GetDetails()
 {
     objconst = new ConstantMessage();
     try
     {
         //currently logged in Windows username
         Console.WriteLine("UserName: {0}", Environment.UserName);
         //Home directory
         Console.WriteLine("Home Directory:" + Environment.CurrentDirectory);
         //OS name
         Console.WriteLine("OS name: {0}", Environment.OSVersion);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 21
0
 ConstantMessage objconst;//object creation
 /// <summary>
 ///Method Name:FileReadException
 /// Description://Reading the text from file and Handle Exception while generate
 /// Author:bhumi
 /// Created On:22/5/2015
 /// </summary>
 public void FileReadException()
 {
     try
     {
         string   filename;
         string[] lines;
         objconst = new ConstantMessage();
         // Read each line of the file into a string array. Each element
         // of the array is one line of the file.
         Console.WriteLine(objconst.strfilename);
         filename = Console.ReadLine();
         lines    = System.IO.File.ReadAllLines(@"D:\" + filename + ".txt");
         //check file Existance
         Console.WriteLine(File.Exists(@"D:\" + filename + ".txt") ? objconst.strfileexist : objconst.strfilenotexist);
         //Check file text is null or not
         if (new FileInfo(@"D:\" + filename + ".txt").Length == 0)
         {
             Console.WriteLine(objconst.strfilenull);
         }
         else
         {
             // Display the file contents by using a foreach loop.
             System.Console.WriteLine(objconst.strfilecontent);
             foreach (string line in lines)
             {
                 // Use a tab to indent each line of the file.
                 Console.WriteLine("\t" + line);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 22
0
        ConstantMessage objconst; //object creation
        /// <summary>
        ///Method Name:GetDate
        /// Description://Create Structure to store date
        /// Author:bhumi
        /// Created On:22/5/2015
        /// </summary>
        public void GetDate()
        {
            List <DateTime> arraylistdate = new List <DateTime>();//Typed arraylist

            try
            {
                Str_Date s1;
                int      dt1, mn1, yr1;
                objconst = new ConstantMessage();
                Console.WriteLine(objconst.strdate);
                dt1 = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(objconst.strmonth);
                mn1 = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(objconst.stryear);
                yr1   = Convert.ToInt32(Console.ReadLine());
                s1.Dt = dt1;
                s1.mn = mn1;
                s1.yr = yr1;
                // Use DateTime.TryParse when input is valid.
                string   input    = s1.Dt + "-" + s1.mn + "-" + s1.yr;
                DateTime dateTime = new DateTime(yr1, mn1, dt1);
                arraylistdate.Add(dateTime);
                foreach (DateTime i in arraylistdate)
                {
                    Console.WriteLine(i.ToShortDateString());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(objconst.strinvalid);
                GetDate();
            }
            finally
            {
                objconst = null;
            }
        }
Ejemplo n.º 23
0
        ConstantMessage objconst;//object creation
        /// <summary>
        ///MethodName:FindSwitchVowel
        /// Description://check that entered character is vowel or not using switch case
        /// Author:bhumi
        /// Created On:21/5/2015
        /// </summary>
        ///
        public void FindSwitchVowel()
        {
            //Modify the above code to use switch-case construct
            try
            {
                objconst = new ConstantMessage();
                Console.WriteLine(objconst.strChar);
                char ch = Convert.ToChar(Console.ReadLine());//get the character from user
                switch (ch)
                {
                case 'a':
                case 'A':
                case 'e':
                case 'E':
                case 'i':
                case 'I':
                case 'o':
                case 'O':
                case 'u':
                case 'U':
                    Console.WriteLine(objconst.strVowel);
                    Console.ReadLine();
                    break;

                default:
                    Console.WriteLine(objconst.strconsonant);
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                objconst = null;
            }
        }
Ejemplo n.º 24
0
 ConstantMessage objconst;//object creation
 ///<summary>
 ///Method Name:FindPowerNum
 /// Description://Power function
 /// Author:bhumi
 /// Created On:21/5/2015
 /// </summary>
 public void FindPowerNum()
 {
     try
     {
         int N_Base, M_power;
         objconst = new ConstantMessage();
         Console.WriteLine(objconst.strfindpower);
         Console.WriteLine(objconst.strbase);
         N_Base = Convert.ToInt32(Console.ReadLine());
         Console.WriteLine(objconst.strpower);
         M_power = Convert.ToInt32(Console.ReadLine());
         //find the N^M
         double result = Math.Pow(N_Base, M_power);
         Console.WriteLine(N_Base + "^" + M_power + "=" + result);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Class Name:Program
        /// Description:Class which containts Main Method.
        /// Author:
        /// Created On:18/5/2015
        /// </summary>
        ///
        #region Main method Class

        static void Main(string[] args)
        {
            List <object> arrylist;
            List <object> objarrylist;
            ArrayList     arraylist_objects;

            arrylist          = new List <object>();
            objarrylist       = new List <object>();
            arraylist_objects = new ArrayList();
            try
            {
                #region Define objects
                //object creation
                ConstantMessage      objconst;
                Program              objprogram;
                Vowel                objvowel;
                SwichVowel           objswitchvowel;
                CaseCheck            objcscheck;
                Reverse              objreverse;
                Sort                 objsort;
                SearchArray          search_arra;
                ReviseArray          revise_arra;
                CopyArray            objcopyarr;
                Power                objpower;
                NotepadFile          objfile;
                WindowDetails        objwindetails;
                Customer             objcustomer;
                Entity               objentity;
                Franchisee           objfranch;
                Bubble_Sort          objbubblesort;
                Array_Transformation objarrtransform;
                DoubleToInt          objdbint;
                Structure            objstrct;
                Structure_Datesort   objstructdatesort;
                objstructdatesort = new Structure_Datesort();
                FileWrite          objfilewrite;
                FileRead_Exception objfileread;
                objconst = new ConstantMessage();
                StringBuilder_Str objstringbuilder;
                child             objchild;
                Driver            objdriver;
                Vehicle           objvehicle;
                Car objcar;
                //Arraylist_objects objarylistobj;
                ArmoredVehicle       objarmoredvehicle;
                IVehicle             objinterfaceIvehicle;
                vehicle              objinterfacevehicle;
                Car7_10              objcar7_10;
                IFuelConsumption     objfuelinterfaceCar;
                IFuelConsumption     objfuelinterfacearmored;
                Fuel7_11             objfuel;
                Hashtable_Sortedlist objhash;
                #endregion
                while (true)
                {
                    //object
                    #region Objects Initialization
                    objprogram              = new Program();
                    objvowel                = new Vowel();
                    objswitchvowel          = new SwichVowel();
                    objcscheck              = new CaseCheck();
                    objreverse              = new Reverse();
                    objsort                 = new Sort();
                    search_arra             = new SearchArray();
                    revise_arra             = new ReviseArray();
                    objcopyarr              = new CopyArray();
                    objpower                = new Power();
                    objfile                 = new NotepadFile();
                    objwindetails           = new WindowDetails();
                    objcustomer             = new Customer();
                    objentity               = new Entity();
                    objfranch               = new Franchisee();
                    objbubblesort           = new Bubble_Sort();
                    objarrtransform         = new Array_Transformation();
                    objdbint                = new DoubleToInt();
                    objstrct                = new Structure();
                    objfilewrite            = new FileWrite();
                    objfileread             = new FileRead_Exception();
                    objstringbuilder        = new StringBuilder_Str();
                    objchild                = new child();
                    objdriver               = new Driver();
                    objvehicle              = new Vehicle();
                    objcar                  = new Car();
                    objinterfaceIvehicle    = new Car();
                    objinterfacevehicle     = new ArmoredVehicle();
                    objarmoredvehicle       = new ArmoredVehicle();
                    objfuelinterfaceCar     = new Car();
                    objfuelinterfacearmored = new ArmoredVehicle();
                    objfuel                 = new Fuel7_11();
                    objhash                 = new Hashtable_Sortedlist();
                    #endregion
                    //objarylistobj = new Arraylist_objects();
                    //Get the input from user AS Day.Exercise No.
                    string a;
                    Console.WriteLine(objconst.strExer);
                    a = Console.ReadLine();
                    //Display the No. of Day
                    string dy = a.Substring(0, 1);
                    Console.WriteLine("Day=" + dy);
                    int intDy = Convert.ToInt32(dy);

                    //Display the No. of Exercise
                    string ex = a.Substring(2);
                    Console.WriteLine("Exercise No.=" + ex);
                    int intEx = Convert.ToInt32(ex);
                    if (intDy > 9 || intDy < 0)
                    {
                        Console.WriteLine(objconst.strday);
                    }
                    else if (intEx > 18)
                    {
                        Console.WriteLine(objconst.strExercise);
                    }
                    else
                    {
                        Console.WriteLine("Code for " + intDy + "." + intEx);
                        Console.WriteLine("*************************************************");
                        //code for Day1
                        if (intDy == 1)
                        {
                            Console.WriteLine(objconst.ShowMessage1);
                            objprogram.Exit();
                        }
                        else
                        {
                            switch (a)
                            {
                            case "2.1":
                            case "3.1":
                                objvowel.FindVowel();
                                objprogram.Exit();
                                break;

                            case "2.2":
                            case "3.2":
                                objswitchvowel.FindSwitchVowel();
                                objprogram.Exit();
                                break;

                            case "2.3":
                            case "3.3":
                                objcscheck.CountChar();
                                objprogram.Exit();
                                break;

                            case "2.4":
                            case "3.4":
                                objreverse.ArrayReverse();
                                objprogram.Exit();
                                break;

                            case "2.5":
                            case "3.5":
                                objsort.ArraySort();
                                objprogram.Exit();
                                break;

                            case "2.6":
                            case "3.6":
                                search_arra.SearchFunction();
                                objprogram.Exit();
                                break;

                            case "2.7":
                            case "3.7":
                                revise_arra.CountFunction();
                                objprogram.Exit();
                                break;

                            case "2.8":
                            case "3.8":
                                objcopyarr.ThreeArray();
                                objprogram.Exit();
                                break;

                            case "2.9":
                            case "3.9":
                                objpower.FindPowerNum();
                                objprogram.Exit();
                                break;

                            case "2.10":
                            case "3.10":
                                objfile.OpenFile();
                                objprogram.Exit();
                                break;

                            case "2.11":
                            case "3.11":
                                objwindetails.GetDetails();
                                objprogram.Exit();
                                break;

                            case "4.1":
                            case "5.1":
                            case "6.1":
                            case "4.2":
                            case "5.2":
                            case "6.2":
                                Console.WriteLine(objconst.strCustomerMethod);
                                objcustomer.Load();
                                objcustomer.Save();
                                objcustomer.Validate();
                                objprogram.Exit();
                                break;

                            case "4.3":
                            case "5.3":
                            case "6.3":
                                Console.WriteLine(objconst.strEntityProp);
                                Console.WriteLine(objentity);
                                objprogram.Exit();
                                break;

                            case "4.4":
                            case "5.4":
                            case "6.4":
                                Console.WriteLine(objconst.strchildclass);
                                objprogram.Exit();
                                break;

                            case "4.5":
                            case "5.5":
                            case "6.5":
                            case "4.6":
                            case "5.6":
                            case "6.6":
                                objfranch.GetFees();
                                Console.WriteLine(objfranch);
                                objprogram.Exit();
                                break;

                            case "4.7":
                            case "5.7":
                            case "6.7":
                            case "4.8":
                            case "5.8":
                            case "6.8":
                                Console.WriteLine(objconst.strcustomernum);
                                int num_customer1 = Convert.ToInt32(Console.ReadLine());
                                for (int i = 0; i < num_customer1; i++)
                                {
                                    Console.WriteLine(objconst.strcustomerno);
                                    objentity.Property_Method_Entity();
                                    arraylist_objects.Add(objentity);
                                }
                                Console.WriteLine(objconst.strfranchcount);
                                int num_franch1 = Convert.ToInt32(Console.ReadLine());
                                for (int i = 0; i < num_franch1; i++)
                                {
                                    objfranch.GetFees();
                                    arraylist_objects.Add(objfranch);
                                }
                                foreach (object obj in arraylist_objects)
                                {
                                    Console.WriteLine(obj);
                                }
                                objprogram.Exit();
                                break;

                            case "4.9":
                            case "5.9":
                            case "6.9":
                                Console.WriteLine(objconst.strcustomernum);
                                int num_customer = Convert.ToInt32(Console.ReadLine());
                                for (int i = 0; i < num_customer; i++)
                                {
                                    Console.WriteLine(objconst.strcustomerno);
                                    objcustomer.Property_Method();
                                    arrylist.Add(objcustomer);
                                }
                                Console.WriteLine(objconst.strfranchcount);
                                int num_franch = Convert.ToInt32(Console.ReadLine());
                                for (int i = 0; i < num_franch; i++)
                                {
                                    objfranch.GetFees();
                                    arrylist.Add(objfranch);
                                }
                                objprogram.Exit();
                                break;

                            case "4.10":
                            case "5.10":
                            case "6.10":
                                foreach (object obj in arrylist)
                                {
                                    Console.WriteLine(obj);
                                }
                                objprogram.Exit();
                                break;

                            case "4.11":
                            case "5.11":
                            case "6.11":
                                objbubblesort.BubbleSort();
                                objprogram.Exit();
                                break;

                            case "4.12":
                            case "5.12":
                            case "6.12":
                                objarrtransform.Trasform();
                                objprogram.Exit();
                                break;

                            case "4.13":
                            case "5.13":
                            case "6.13":
                                objdbint.DataTypeConv();
                                objprogram.Exit();
                                break;

                            case "4.14":
                            case "5.14":
                            case "6.14":
                                Console.WriteLine(objconst.strstringbuilder);
                                Console.WriteLine(objconst.strintnum);
                                int inputNumber = Convert.ToInt32(Console.ReadLine());
                                Console.WriteLine(objstringbuilder.NumbersToWords(inputNumber));
                                objprogram.Exit();
                                break;

                            case "4.15":
                            case "5.15":
                            case "6.15":
                                Console.WriteLine(objconst.strdatecount);
                                int datecount = Convert.ToInt32(Console.ReadLine());
                                for (int i = 0; i < datecount; i++)
                                {
                                    objstrct.GetDate();
                                }
                                objprogram.Exit();
                                break;

                            case "4.16":
                            case "5.16":
                            case "6.16":
                                Console.WriteLine(objconst.strdatecount);
                                int datecount_sort = Convert.ToInt32(Console.ReadLine());
                                for (int i = 0; i < datecount_sort; i++)
                                {
                                    objstructdatesort.Getdate_Struct();
                                }
                                Console.WriteLine(objconst.stractualdate);
                                objstructdatesort.Print();
                                objprogram.Exit();
                                break;

                            case "4.17":
                            case "5.17":
                            case "6.17":
                                objfilewrite.WriteToFile();
                                objprogram.Exit();
                                break;

                            case "4.18":
                            case "5.18":
                            case "6.18":
                                objfileread.FileReadException();
                                objprogram.Exit();
                                break;

                            //day 7,8 & 9
                            case "7.1":
                            case "8.1":
                            case "9.1":
                                objdriver.Drive();
                                objprogram.Exit();
                                break;

                            case "7.2":
                            case "8.2":
                            case "9.2":
                                objchild.GetCarClass();
                                objprogram.Exit();
                                break;

                            case "7.3":
                            case "8.3":
                            case "9.3":
                                objcar.Drive72();
                                objprogram.Exit();
                                break;

                            case "7.4":
                            case "8.4":
                            case "9.4":
                                objvehicle.Drive();    //method of Vehicle class which contains in Vehicles namespace
                                objcar.Drive72();
                                objprogram.Exit();
                                break;

                            case "7.5":
                            case "8.5":
                            case "9.5":
                            case "7.6":
                            case "8.6":
                            case "9.6":
                                objinterfaceIvehicle.Destruct();
                                objinterfacevehicle.Destruct();
                                objprogram.Exit();
                                break;

                            case "7.7":
                            case "8.7":
                            case "9.7":
                                Console.WriteLine(objconst.strcountcarobj);
                                int countcar = Convert.ToInt32(Console.ReadLine());
                                Console.WriteLine(objconst.strcountarmoredobj);
                                int countarmored = Convert.ToInt32(Console.ReadLine());
                                for (int i = 0; i < countcar; i++)
                                {
                                    objinterfaceIvehicle.Destruct();
                                    arrylist.Add(objinterfaceIvehicle);
                                }
                                for (int i = 0; i < countarmored; i++)
                                {
                                    objinterfacevehicle.Destruct();
                                    arrylist.Add(objinterfacevehicle);
                                }
                                foreach (object s in arrylist)
                                {
                                    Console.WriteLine(s);
                                }
                                objprogram.Exit();
                                break;

                            case "7.8":
                            case "8.8":
                            case "9.8":
                                ArrayList arrylist1 = new ArrayList();
                                objinterfacevehicle.Destruct();
                                arrylist1.Add(objinterfacevehicle);
                                foreach (object s in arrylist1)
                                {
                                    Console.WriteLine(s);
                                }
                                objprogram.Exit();
                                break;

                            case "7.9":
                            case "8.9":
                            case "9.9":
                                Console.WriteLine(objconst.strcountcarobj);
                                int countcarobj = Convert.ToInt32(Console.ReadLine());
                                for (int i = 0; i < countcarobj; i++)
                                {
                                    arrylist = new List <object>();
                                    objinterfaceIvehicle.Destruct();
                                }
                                for (int i = 0; i < countcarobj; i++)
                                {
                                    string strmodelname = objcar.ModelName;
                                    arrylist.Add(strmodelname);
                                }
                                foreach (object s in arrylist)
                                {
                                    Console.WriteLine(s);
                                }
                                objprogram.Exit();
                                break;

                            case "7.10":
                            case "8.10":
                            case "9.10":
                                Console.WriteLine(objconst.strcountcarobj);
                                int    countcar7_10obj = Convert.ToInt32(Console.ReadLine());
                                string strcarmodelnm;
                                arrylist = new List <object>();
                                for (int i = 0; i < countcar7_10obj; i++)
                                {
                                    Console.WriteLine(objconst.strmodelnm);
                                    strcarmodelnm = Console.ReadLine();
                                    objcar7_10    = new Car7_10(strcarmodelnm);
                                    string s1 = objcar7_10.ModelName;
                                    arrylist.Add(s1);
                                }
                                Console.WriteLine("******************");
                                foreach (object s in arrylist)
                                {
                                    Console.WriteLine(s);
                                }
                                objprogram.Exit();
                                break;

                            case "7.11":
                            case "8.11":
                            case "9.11":
                            case "7.12":
                            case "8.12":
                            case "9.12":
                                int kmcar, initfuelcar, effcar;             //variasbles for car
                                int kmarmored, effarmored, initfuelarmored; //variables for armored vehicle
                                //For Car
                                Console.WriteLine(objconst.strinitialfuelcar);
                                initfuelcar = Convert.ToInt32(Console.ReadLine());
                                objcar      = new Car(initfuelcar);
                                Console.WriteLine(objconst.strincar + initfuelcar);
                                kmcar = objfuelinterfaceCar.Drive7_11();
                                //For Armored Vehicle
                                Console.WriteLine(objconst.strinitialfuelarmored);
                                initfuelarmored   = Convert.ToInt32(Console.ReadLine());
                                objarmoredvehicle = new ArmoredVehicle(initfuelarmored);
                                Console.WriteLine(objconst.strinArm + objarmoredvehicle.InitialFuel);
                                kmarmored = objfuelinterfacearmored.Drive7_11();
                                //Fuel Efficiency for car
                                Console.WriteLine(objconst.strfueleffcar);
                                effcar = Convert.ToInt32(Console.ReadLine());
                                objcar.FuelEfficiency = effcar;
                                Console.WriteLine(objconst.streffcar + objcar.FuelEfficiency);
                                //Fuel efficiency for armored
                                Console.WriteLine(objconst.strfueleffarmored);
                                effarmored = Convert.ToInt32(Console.ReadLine());
                                objarmoredvehicle.FuelEfficiency = effarmored;
                                Console.WriteLine(objconst.streffArm + objarmoredvehicle.FuelEfficiency);
                                int leftfuel_car = ((kmcar * initfuelcar) - (effcar));
                                if (leftfuel_car <= 0)
                                {
                                    objfuel.NoFuelExe();
                                }
                                else
                                {
                                    Console.WriteLine(objconst.strleftcar + leftfuel_car);
                                }
                                int leftfuel_armored = ((kmarmored * initfuelarmored) - (effarmored));
                                if (leftfuel_armored <= 0)
                                {
                                    objfuel.NoFuelExe();
                                }
                                else
                                {
                                    Console.WriteLine(objconst.strleftArm + leftfuel_armored);
                                }
                                objprogram.Exit();
                                break;

                            case "7.13":
                            case "8.13":
                            case "9.13":
                                objhash.GetobjectHashTable();
                                objprogram.Exit();
                                break;

                            default:
                                Console.WriteLine(objconst.ShowMessage1);
                                objprogram.Exit();
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Program objpr = new Program();
                objpr.Exit();
            }
        }
Ejemplo n.º 26
0
 ConstantMessage objconst;//object creation
 ///<summary>
 ///Method Name:ThreeArray
 /// Description://create one array,input of this array will be from other two arrays.
 /// Author:bhumi
 /// Created On:21/5/2015
 /// </summary>
 public void ThreeArray()
 {
     try
     {
         objconst = new ConstantMessage();
         //Initialization
         int[]    array1 = new int[5];
         int[]    array2 = new int[5];
         double[] array3 = new double[10];
         //First Array
         Console.WriteLine(objconst.strinput);
         for (int i = 0; i < array1.Length; i++)
         {
             array1[i] = Convert.ToInt32(Console.ReadLine());
         }
         Console.WriteLine("==============================================");
         //Second Array
         Console.WriteLine(objconst.strinput);
         for (int i = 0; i < array1.Length; i++)
         {
             array2[i] = Convert.ToInt32(Console.ReadLine());
         }
         Console.WriteLine("==============================================");
         //Third Array
         Console.WriteLine(objconst.strcombine);
         int i1 = 0;
         for (int j = 0; j < 10; j++)
         {
             if (j % 2 == 0)
             {
                 //Second array at even position of third array
                 array3[j] = array2[i1];
                 i1        = i1 + 1;
             }
             else
             {
             }
         }
         int i2 = 0;
         for (int j = 0; j < 10; j++)
         {
             if (j % 2 == 0)
             {
             }
             else
             {
                 //First array at odd position of third array
                 array3[j] = array1[i2];
                 i2        = i2 + 1;
             }
         }
         //output of third array
         for (int i = 0; i < 10; i++)
         {
             Console.WriteLine(array3[i]);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         objconst = null;
     }
 }