c# queston Rename Program class “FriendDriver” and place the following in the Ma
ID: 3760079 • Letter: C
Question
c# queston
Rename Program class “FriendDriver” and place the following in the Main class:
class FriendDriver
{
static void Main(string[] args)
{
Console.WriteLine("A list of my friends"); Console.WriteLine("-----------------------------");
Friend f1 = new Friend();
Friend f2 = new Friend();
f1.setFriend("Cynthia", "Fleece", 29);
f2.setFriend("Rebecca", "Mace", 20);
f1.displayFriend();
f2.displayFriend()
; Console.ReadLine();
}
}
Create a second class in your Visual Studio project by choosing “Project->Add Class”. This class should be called Friend and should contain: 3 private instance variables – firstName, lastName, and age 2 public methods –
1. one called setFriend that accepts friend’s first name, last name and age and stores those values in the 3 instance variables
2. one called displayFriend that displays a friend’s details to the console Your program should produce exactly the following output:
Explanation / Answer
class Friendvs
{
static void Main(string[] args)
{
Console.WriteLine("A list of my friends"); Console.WriteLine("-----------------------------");
public setFriend(string firstName,string lastName,int age)
{}
public displayFriend()
{ System.out.println(lastName", "firstName". "age" yo");
}
Friend f3 = new Friend();
Friend f4 = new Friend();
f3.setFriend("Cynthia", "Fleece", 29);
f4.setFriend("Rebecca", "Mace", 20);
f3.displayFriend();
f4.displayFriend()
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.