Code:
/*
* Created by SharpDevelop.
* User: Back_Track
* Date: 4/4/2010
* Time: 11:29 PM
*/
using System;
namespace class_
{
class Program
{
public static void Main(string[] args)
{
int choice;//Just for the 1,2 choice
Programming Pascal = new Programming();//Create a variable with the values of the Programmig Class
Pascal.Scripted = false;//Set the variables from the class
Pascal.IsOO = false;
Pascal.Year_Made = 1968; //1968/9 Published 1970
Pascal.Operating_Systems = "Windows/Mac/Linux";
Programming Cxx = new Programming();//C++
Cxx.Scripted = false;
Cxx.IsOO = true;
Cxx.Year_Made = 1983;
Cxx.Operating_Systems = "Windows/Mac/Linux";
Console.WriteLine("Lets test your programming knowledge!\nWhich Language would you like to be tested on.\n1)Pascal\n2)C++");
Int32.TryParse(Console.ReadLine(),out choice);
string Script,IsOO,OS;//For checking
int Year,right=0;
if(choice == 1)
{
Console.WriteLine("Is Pascal a scripted language? (Answers, yes or no)");
Script = Console.ReadLine();//Get input
Console.WriteLine("Is Pascal Objected Oriented? (Answers, yes or no)");
IsOO = Console.ReadLine();
Console.WriteLine("What year was pascal invented? (Answers, Numeric)");
Int32.TryParse(Console.ReadLine(), out Year);
Console.WriteLine("What Operating Systems is Pascal available on (Answers, Windows/Mac/Linux)");
OS = Console.ReadLine();
if(Script == "no")
{
right++;//If you got it right increment the 'correct' int
}
if(IsOO == "no")
{
right++;
}
if(Year == Pascal.Year_Made )
{
right++;
}
if( OS == Pascal.Operating_Systems)
{
right++;
}
Console.WriteLine("You got {0}/4 right",right);
}
if(choice == 2)
{
Console.WriteLine("Is C++ a scripted language? (Answers, yes or no)");
Script = Console.ReadLine();
Console.WriteLine("Is C++ Objected Oriented? (Answers, yes or no)");
IsOO = Console.ReadLine();
Console.WriteLine("What year was C++ invented? (Answers, Numeric)");
Int32.TryParse(Console.ReadLine(), out Year);
Console.WriteLine("What Operating Systems is C++ available on (Answers, Windows/Mac/Linux)");
OS = Console.ReadLine();
if(Script == "no")
{
right++;
}
if(IsOO == "yes")
{
right++;
}
if(Year == Cxx.Year_Made )
{
right++;
}
if( OS == Cxx.Operating_Systems)
{
right++;
}
Console.WriteLine("You got {0}/4 right",right);
}
else{
}
Console.ReadLine();
}
class Programming//Create a class of Programmign
{
public bool Scripted;
public bool IsOO;//Self Explanatory
public int Year_Made;
public string Operating_Systems;
}
}
}
Simple Class example , with explanation.