Skip To Content
    Dashboard
    • Login
    • Dashboard
    • Courses
    • Calendar
    • 0
      Inbox
    Close
    • My Dashboard
    • Assignments
    • Lab Tutorial - 3
    2022-23 (Odd)
    • Home
    • Modules

    Lab Tutorial - 3

    • Due No Due Date
    • Points 10
    • Submitting a file upload

    Sample Format for file upload.docx

     

    1 : Draw a real picture for class and object. Differentiate class and object in terms of diagram only.

    Perform following tasks.

    Task 1: Create a class

    Task 2: Add few data members as private

    Task 3: Add few methods as public to work on defined data members

    Task 4: Create a Demo class with main method.

    Task 5: Create at least two objects of a class defined in Task 1 into main method and call all methods using that object.

    Task 6: Write comment for each important portion of code like data members’ declaration, methods, some important logic etc.

    Task 7: Summarize above solution in your own few words to visualize the solution to the end user.

     

    2 : Define a class Clock with three private integer data members hour, min and sec. Define a no argument constructor to initialize time value to 12:00:00. Define a three argument constructor to initialize the time.
    Define a methods to

      1. Increment time to next second.
      2. Display the time value.
      3. Return the hour (int getHour())
      4. Return the minute (int getMinute())
      5. Return the seconds (int getSeconds())

    3 : Define a Student class with appropriate data members, property, constructors, methos etc. Define another class called TestStudent within the same .cs file. Also create an object of student class and demonstrate the use of student class.

    4 : Use above program classes and create objects for 5 students and demonstrate the use student class.

    5 : Rearrange the given code to get the desired output.

     

    using System;

    namespace ConsoleApplication

    {

        class Product

        {

            public Product(int pcd, String pnm, String mnm)

            {

                mname = mnm;

            }

     

            public void Display()

            {

                Console.WriteLine("\nManufacturer Name:= " + mname);

            }

        }

      int pcode;

      String pname, mname;

      Console.WriteLine("\nProduct Code:= " + pcode);

      Console.WriteLine("\nProduct Name:= " + pname);

      pcode = pcd;

      pname = pnm;

     

     

        public class TestProduct

        {

            public static void Main(string[] args)

            {

                int n = args.Length;

     

                if (n < 3)

                {

                    Console.WriteLine("Syntax Error\n");

                    Console.WriteLine("Must Have THREE Arguments\n");

                    Console.WriteLine("Please, Write as [csc TestProduct ProductCode ProductName Manufacturer] \n");

                }

                else

                {

                  

                    Product p=new Product(pcd,pnm,mnm);

                    p.Display();

                    Console.Read();

                    int pcd = Convert.ToInt32(args[0]);

                    String pnm = args[1];

                    String mnm = args[2];

     

                }

            }

        }

    }

    Output:

    Product Code:= P001

    Product Name:= Mouse

    Manufacturer Name:= Logitech

     

    6 : Complete the following code that will generate the given output:

    Solution:

    using System;

    namespace LineApplication

    {

       class Line

       {

          private double length;   // Length of a line

          public Line()

          {

              //………………………………Missing statement-1……………………………….// 

             //………………………………Missing statement-2……………………………….// 

          }

     

          public void setLength( double len )

          {

              //………………………………Missing statement-3……………………………….//      

     

          }

          public double getLength()

          {

              //………………………………Missing statement-4……………………………….//      

          }

    }

     

    class TestLine

    {

          static void Main(string[] args)

          {

             Line line = new Line();   

             // set line length

             Console.WriteLine("Length of line : {0}", line.getLength());

             // set line length

             Console.WriteLine("Length of line : {0}", line.getLength());

             Console.ReadKey();

          }

       }

    }

    Output:

    Object is being created, length = 10

    Length of line : 10

    Length of line : 6

     

    7 : Define EnrolmentNo and Name properties for the Student class and demonstrate use of these properties along with required data members, methods and constructors.

     

    0
    Additional Comments:
    Rating max score to > pts

    Rubric

     
     
     
     
     
         
    Can't change a rubric once you've started using it.  
    Find a Rubric
    Find Rubric
    Title
    You've already rated students with this rubric. Any major changes could affect their assessment results.
    Title
    Criteria Ratings Pts
    Edit criterion description Delete criterion row
    This criterion is linked to a Learning Outcome Description of criterion
    view longer description
    threshold: 5 pts
    Edit rating Delete rating
    5 to >0 pts
    Full Marks
    blank
    Edit rating Delete rating
    0 to >0 pts
    No Marks
    blank_2
    This area will be used by the assessor to leave comments related to this criterion.
    pts
      / 5 pts
    --
    Additional Comments
    Total Points: 5 out of 5
    In order to create video or audio recordings your computer needs to be webcam-enabled. If you don't have a webcam on your computer, you can still record audio-only messages by first installing the Google Video Chat plugin.
    Install the Video Plugin
    Don't have a webcam?