Showing posts with label C# LAB at HoM 1. Show all posts
Showing posts with label C# LAB at HoM 1. Show all posts

Wednesday, 24 April 2013

Predict the output of the following code snippet: using System; class Myclass { static void Main() { string Answer="Y"; string Response_code="66"; int Counter=60; Console.WriteLine(Answer); Console.WriteLine(Response_code); Console.WriteLine(Counter); Console.ReadLine(); } } (Duration: 15 min)


using System;
class Myclass
{
static void Main()
{
string Answer="Y";
string Response_Code="66";
int Counter=60;
Console.writeLine(Answer);
Console.WriteLine("Response Code");
Console.WriteLine(Cunter);
Console.ReadLine();
 }
}

Jim is developing software for automating the slot booking process for a video game parlor. Customers fill the Booking Request form with the details of the game, such as the name, number of players, and complexity level. They hand over the form to the booking officer at the parlor. Depending on the availability, the booking officer reserves the time slots and the play station for customers. Identify the involved classes and objects, and their attributes. Write methods in the class to accept the game details and display them. (Duration: 45 min)


using system ;
public class gamedetials
{

      string fname ;
      string lname ;
      int noofplayer ;
      int level ;
   
      public static void getGameDetail ()
{
      console.writeline (" enter your first name" );
      fname= console.readline();
      console. writeline ( " enter your last name" );
      Lname-console.readline();
      console.writeline( "enter no of players");
      nooFplayer=convert ToInt32(console. readline() )  
      console. writeline(" entercomplexity level number:");
      level= convert ToInt32(console.readline());
          Console.ReadLine();
}




 
public static void showGameDetails()
{
   {
 console. writeline("the details enter are as follows:");
  console. write("first name:");
 console.writeline(fname);
 console.write("last name:");
 console.writeline(lname);
 console.write("no of players:");
 console.writeline(noofplayers);
 console.write("level:");
 console.writeline(level);
     
public static void Main(string []args)
{
GameDetails gd=new GameDetails();
gd.getGameDetials();
gd.showGameDetails();

}
}
                       

Diaz Entertainment, Inc. has to develop a software application for young children that would enable them to identify and distinguish shapes and colors. The application should ask the name of the shape, its area, and color. Once the input is provided, the application should draw the shape with the same area and color as entered by the user. You, as part of the development team, have to define the Geometrical_Shapes class that should have methods to accept the input from the users, display the input as entered by the user, and display the shapes with the same color and area. You have written the following code: class Geometrical_Shapes { Double Area; string shape; string Color; public: void GetInput () { //Code to accept the user inputs and store the values in //the corresponding variables } void Display() { //Code to display the details of the shape such as //no_of_coordinates, area, and color } } You thought of showing this class to your supervisor before adding the method to draw the shapes. However, your supervisor told you that the class definition contains errors. In addition, he asked you to complete the methods. Now, you need to fix the errors and complete the GetInput() and Display() methods. You also need to write the Main() method so that the code can be compiled and executed.



using system;
class Geometrical_shapes
{
    double Area;
    string Shape;
    string color;
 public void GetInput()
{
   console.write("Enter the of the Shape:");
   Shape = console.ReadLine();
   console.Write("Enter the Color:");
   Color = Console.ReadLine();
   Console.Write("Enter the Area:");
   Area = Console.ToDouble(console.ReadLine());
}
Publicvoid Display ()
{
   Console.WriteLine();
   Console.WriteLine("THISIS WHAT YOU ENTERED: \n");
   console.write("Name of the Shape:");
   console.WriteLine(Shape);
   console.write("Color:");
   Console.WriteLine("Color");
   Console.write("Area:");
   Console.writeLine(Area);
  }
}
class Classy
{
 static void Main(string[]args)
{
 Geometrical Shapes_Small_rectangle = new Geometrical_Shapes();
 Small rectangle.Create();
 Small rectangle.Display();
 Console.ReadLine();
  }
}