TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
328.2k
Method
Dec 3 2011 11:19 AM
Instead of having WriteLine() method three times I wish to know whether is there any way to deploy display() method as shown in the following and develop the program appropriately.
// Creates a Boat class
// And instantiates three Boat objects
using System;
public class DebugFour1
{
public static void Main()
{
Boat aRowBoat = new Boat();
Boat aSkiBoat = new Boat();
Boat aYacht = new Boat();
aRowBoat.SetLicense("W2453");
aRowBoat.SetState("WI");
aSkiBoat.SetLicense("M6120");
aSkiBoat.SetState("MI");
aYacht.SetLicense("M5322");
aYacht.SetState("MA");
display(aRowBoat);
display(aSkiBoat);
display(aYacht);
}
static void display(object aBoat)
{
Console.WriteLine("Boat {0} from {1} has a {2} HP motor.", aBoat.GetLicense(), aBoat.GetState(), aBoat.GetMotor());
}
}
class Boat
{
private string licenseNum;
private string state;
public string GetLicense()
{
return licenseNum;
}
public string GetState()
{
return state;
}
public void SetLicense(string licNum)
{
licenseNum = licNum;
}
public void SetState(string st)
{
state = st;
}
}
Reply
Answers (
6
)
C# argument out of range was unhandled due to the SelectedIndex
What is used of System.Text.StringBuilder