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
Matt Vowells
NA
1
0
c# no Overload for method'method name' takes 0 arguments
Aug 22 2009 8:19 AM
I can't sem to run my methods from the form.cs. I keep getting the above error. My Code is below. form1.cs namespace aDayAtTheRaces { public partial class Form1 : Form { public int MinBet; public Form1() { InitializeComponent(); //set the minimum bet; //initialize Greyhound index array //initialize each Greyhound object and relevant fields/properties Greyhound[] dogs = new Greyhound[4]; dogs[0] = new Greyhound() { MyPictureBox = pictureBox2}; dogs[1] = new Greyhound() { MyPictureBox = pictureBox3}; dogs[2] = new Greyhound() { MyPictureBox = pictureBox4}; dogs[3] = new Greyhound() { MyPictureBox = pictureBox5}; //initialize Guy index array //initialize each Guy object and relevant fields/properties Guy[] guys = new Guy[3]; guys[0] = new Guy() { Cash = 50, Name = "Joe", MyBet = null, MyRadioButton = radioButtonJoe, MyLabel = labelJoe}; guys[1] = new Guy() { Cash = 75, Name = "Bob", MyBet = null, MyRadioButton = radioButtonBob, MyLabel = labelBob}; guys[2] = new Guy() { Cash = 45, Name = "Al", MyBet = null, MyRadioButton = radioButtonAl, MyLabel = labelAl}; int Dog = (int)dogNumber.Value; int RacetrackLength = pictureBox1.Width; } private void buttonBets_Click(object sender, EventArgs e) { Bet.GetDescription(); Guy.PlaceBet(); } private void buttonRace_Click(object sender, EventArgs e) //If the dogs location property is greater than start location but less than max location keep running //If not display box that says "Please wait until race finishes" { Greyhound.Run(); } Grehound cs namespace aDayAtTheRaces { public class Greyhound { public int StartingLocation; public int RacetrackLength; public PictureBox MyPictureBox = null; public int Location = 0; public Random Randomiser; public bool winner; public bool Run() //Move dog forward either 1, 2, 3 or 4 spaces at random and update the position of my PictureBox and //return true if I won the race { Greyhound[] dogs = new Greyhound[4]; int[] spaces = { 1, 2, 3, 4 }; while (winner == false) { //Generating random number (1-4) and calling it X int distance = spaces[Randomiser.Next(spaces.Length)]; for (int i = 0; i < 4; i++) { //for each dog add the number on to the X point System.Drawing.Point p = MyPictureBox.Location; p.X += distance; MyPictureBox.Location = p; dogs[i].MyPictureBox.Location = new System.Drawing.Point(25, 55); } } MessageBox.Show("We have a winner - dog #" + winner); return true; } public void TakeStartingPosition() // Reset my dogs position to the start line { Greyhound[] dogs = new Greyhound[4]; dogs[0].MyPictureBox.Location = new System.Drawing.Point(25, 55); dogs[1].MyPictureBox.Location = new System.Drawing.Point(25, 116); dogs[2].MyPictureBox.Location = new System.Drawing.Point(25, 183); dogs[3].MyPictureBox.Location = new System.Drawing.Point(25, 249); } } } namespace aDayAtTheRaces { public class Bet { public int Amount; public int Dog; public Guy Bettor; public string GetDescription(string Name, int MyBet, int Dog) //Returns a string that says who placed a bet, on what dog and for how much ("Joe bets £10 on dog #1") //If the amount is zero, display ("'Name' hasn't placed a bet yet") { if (Amount == 0) { return (Name + " hasn't placed a bet."); } else { return (Name + "bets £" + MyBet + " on dog # " + Dog); } } public int PayOut(int Winner) //Parameter is winner of race. If my dog won return the amount bet, otherwise return the negative of the amount bet. { if (Dog == Winner) { return Amount; } else { return -Amount; } } } } namespace aDayAtTheRaces { public class Guy { public String Name; public Bet MyBet; public int Cash; public RadioButton MyRadioButton; public Label MyLabel; public int Amount; public int Dog; public void UpdateLabels() //Set my label to my bets description, and the label on my radio buton to show my cash ("Joe has 35 pounds left") { this.MyRadioButton.Text = (Name + "has " + Cash + " pounds"); this.MyLabel.Text = (Name + "bets " + Amount + "pounds on dog #" + Dog); } public void ClearBet() { this.MyBet = null; } public bool PlaceBet(int Amount, int Dog, String Name) //Place a new bet and store it in my bet field and return true if the guy had enough money to bet { this.MyBet = new Bet(); { if (Cash >= Amount) { Cash = Cash - Amount; MyLabel = new Label(); UpdateLabels(); return true; } else { return false; } } } public void Collect(int Winner) { MyBet.PayOut(Winner); } } }
Reply
Answers (
3
)
mobile phone keypad
Passing parameters to a running winxp service using command line