C# Questions1
C# Questions1
using System;
// Copy constructor
public Person(Person otherPerson)
{
// Copy the values from the otherPerson instance
Name = otherPerson.Name;
Age = otherPerson.Age;
}
class Program
{
static void Main()
{
Instance Variables:
SimNumber:long
SimType:string
1.A parameterized constructor that allows you to set the SimNumber and SimType
2.A Copy constructor copy the data to copy constructor
Methods:
Name:DisplayInfo
ReturnType:string
AccessModifier:public
return the data of the Sim
If you change the sim type for example before simtype is airtel and changed to jio
update the simtype
MethodName:UpdateSimtype
Prameters:NewSimType (string)
Returntype:void
AccessModifier:public
update the simtype.
create object for Sim class pass the values by using constructor and also call the
UpdateSimtype method.
Display the siminformation using copy constructor and also display details after
update
copy constructor details don't has to change it should be having old details
User has to enter the values.
sample output:
------------------
Enter Sim Number:
123456789
Enter Sim Type:
Airtel
3.Create an class Chess should have the following properties:(longest chess game
ever played)
Instance Variables:
GameName:string
no_of_moves:int
year_of_played:int
player1name:string
player2name:string
Methods:
Name:DisplayInfo
ReturnType:string
AccessModifier:public
return GameName,no_of_moves,year_of_played,player1name and player2name
Create ChessGame class pass the values by using constructor and also call the
DisplayInfo method.
Note: The longest chess game ever played took place in 1989 between Ivan Nikolic
and Goran Arsovic and lasted for a total of 269 moves over the course of four days.