Exemple #1
0
        static void Main(string[] args)
        {
            Dog puppy = new Dog("Orion", "Shawn", 1, Gender.Male); // create object instance

            puppy.bark(3);                                         // output: Woof!Woof!Woof!
            Console.WriteLine(puppy.getTag());
        }
        static void Main(string[] args)
        {
            /* part 2
             *
             * The scope of the method is a global scope due it have the "public" keyword signifying that it can be accessed from anywhere. It is a static method as it
             * depends on the parameters height and width to return a value. The return type is a double value as your are multiplying two double values to get your final
             * return value. The method name is getArea and is assigned to be a double value using the double keyword, this tells us that the return value can have decimal
             * point and not be a simple integer. The parameters are hieght and width which are found inside the parentheses, they are the arguements we must supply when
             * calling the method, both are double values. The method body is composed of a math equation where you multiply the two parameters and return the result as a
             * double value to the method.
             *
             * part 3
             * A user defined method is a method defined by us where we have to give the method type (public/private), what value will it return if any (bool, int, char, etc.),
             * what parameters there are, and then we must build the body of the method which is the task it is supposed to fulfill. We can access user defined methods by first
             * typing the class name and then using the method accessor (.) followed by the method name to run our method. A method provided in a framework can simply be
             * accessed by a using directive followed by a namespace. With this we get access to all of the methods in that namespace and don't even have to use the fully
             * quailified name to use them. This is an example of abstraction as we can use the methods but don't know how they work.
             *
             * part 4
             * A static method doesn't not apply to any specific object but rather applies to a whole class. For example, a class of employees all could have the same type of
             * email attribute which could then just be made using a static method. Since the same email format applies to all employees we could use a static method that does
             * not depend on any data to work. The non static method is the complete opposite and requires data to function as well as only focusing on a specific object
             * rather than the whole class.
             */

            //part 5
            Dog myDog = new Dog();

            myDog.Name = "Fido";

            myDog.bark();
            myDog.doTrick("Fetch");
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Dog myDog = new Dog();

            myDog.Name = "Fido";
            myDog.bark();
            myDog.doTrick("Fetch");
        }
Exemple #4
0
        static void Main(string[] args)
        {
            var dog = new Dog("Orion", "Shawn", 1, Dog.Gender.Female);

            dog.bark(3);
            dog.getTag();
            Console.ReadLine();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            Dog myDog = new Dog();

            myDog.Name = "Fido";

            // To do: uncomment the following lines of code to call the methods
            myDog.bark();
            myDog.doTrick("Fetch");
        }
Exemple #6
0
        static void Main(string[] args)
        {
            Dog myDog = new Dog();

            myDog.name = "Fido";


            // To do: uncomment the following lines of code to call the methods
            myDog.bark();
            Console.ReadLine();
        }
Exemple #7
0
        static void Main(string[] args)
        {
            Dog puppy = new Dog("Buddy", "Cassidy", 1, Gender.Male);

            puppy.bark(3);
            Console.WriteLine(puppy.getTag());
            Dog myDog = new Dog("Missy", "Graham", 4, Gender.Female);

            myDog.bark(1);
            Console.WriteLine(myDog.getTag());
            Console.ReadKey();
        }
Exemple #8
0
        public static void Main(string[] args)
        {
            Dog puppy = new Dog("Remi", "Ellen", 3, Gender.Female); // create object instance

            puppy.bark(3);                                          // output: Woof!Woof!Woof!
            Console.WriteLine(puppy.getTag());                      // output: If lost, call Shawn. His name is Orion and he is 1 year old.

            Dog myDog = new Dog("Ollie", "Mercy", 2, Gender.Male);  // create object instance

            myDog.bark(1);                                          // output: Woof!
            Console.WriteLine(myDog.getTag());                      // output: If lost, call Dale. Her name is Lileu and she is 4 years old.
        }
Exemple #9
0
        static void Main(string[] args)
        {
            /*
             * Identify and describe the following elements of the method header given the following method called getArea().
             * You must identify where they are in the method header example, other possible values and what the significance
             * of each is (what does it mean?)
             *
             * a.Scopedouble height, double width. Anything within the () in a method header.
             * b.Static vs. Non-StaticStatic or not static, if static you can access information all across the code. If not static then must fetch information another way.
             * c.Return TypeDouble in this example. Signifies how the program returns information. Can be void, or int aswell.
             * d.Method Name (Identifier)getArea in this example. Tells the code where to go to for information.
             * e.ParametersPublic in this example. Tells the code the access restrictions if any. Public don’t have restrictions private do.
             * f.Method BodyReturn height * width; in this example. Marks the area of code that must be executed
             */


            /*
             * Explain the difference between a user-defined method and a method that is provided with a framework.
             * What should we consider when creating a user-defined method?
             *
             * User defined method is written by the user and are hidden from other methods. Methods provided by the
             * framework are able to be reused from several locations in an app
             *
             */

            /*
             * Discuss the difference between a static and non-static method
             *
             * The difference between a static and non-static method is that a non-static
             * method is allowed to access all the non-static fields in an object. While the static
             * method does not have access to any of the objects non-static fields.
             */

            /*
             * Use the attached code.  Note: you will have to extract the code and open it in Visual Studio before starting.  Add a
             * method to the Dog class called bark(). It should have the following characteristics:
             *
             * a.Zero parameters
             * b.No return value
             * c.Should execute Console.WriteLine("{0} is Barking...", name);
             *
             */
            Dog myDog = new Dog();

            myDog.Name = "Fido";
            myDog.bark();
            myDog.doTrick("Fetch");

            /*Command which allows you close Window*/
            Console.WriteLine("\n \n Press the Enter Key to Close.."); // Command used to display closed message.
            Console.ReadLine();                                        // Command used to keep window open
        }
Exemple #10
0
        static void Main(string[] args)
        {
            Dog puppy = new Dog("Orion", "Shawn", 1, Gender.Male);

            puppy.bark(3);
            Console.WriteLine(puppy.getTag());


            Dog myDog = new Dog("Lileu", "Dale", 4, Gender.Female);

            myDog.bark(1);
            Console.WriteLine(myDog.getTag());
        }
Exemple #11
0
        static void Main(string[] args)
        {
            Dog puppy = new Dog("Orion", "Shawn", 1, Dog.Gender.Male);  // create object instance

            puppy.bark(3);                                              // output: Woof!Woof!Woof!
            Console.WriteLine(puppy.getTag());                          // output: If lost, call Shawn. His name is Orion and he is 1 year old.

            Dog myDog = new Dog("Lileu", "Dale", 4, Dog.Gender.Female); // create object instance

            myDog.bark(1);                                              // output: Woof!
            Console.WriteLine(myDog.getTag());                          // output: If lost, call Dale. Her name is Lileu and she is 4 years old.
            Console.Read();
        }