CFanatic

Go Back   CFanatic > Advance Programming > Game Development

Join CFanatic Forum Now

Basic Battle Game topic posted under Game Development which is a part of Advance Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 04-20-2008, 06:37 PM
Junior Member
 
Join Date: Apr 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Whitfox is on a distinguished road
| More
Basic Battle Game

Hey i have this so far as a little Dos text game
Code:
namespace AutoBattle
{   
        public class Start
        {
            static void Main()
            {
                Fighting.battlemethod();
            }
        }
}

and another class

namespace AutoBattle
{
    class Fighting
    {
        public static void battlemethod(string hero, string Monster, int Damage)
        {
            Console.WriteLine("What is the hero's name");
            hero = Console.ReadLine();
            Console.WriteLine("What is the Monsters name?");
            Monster = Console.ReadLine();
            Console.Write("{0} is facing a {1}",
                hero, Monster);
        }
    }
}
In main the Fighting.Battlemethod is highlighted and the error reads No overload for method "battlemethod" takes '0' arguments.
how do i fix this?

Last edited by Whitfox; 04-20-2008 at 06:42 PM.
Reply With Quote
  #2  
Old 07-25-2008, 01:17 PM
Senior Member
 
Join Date: Jul 2008
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
xpi0t0s is on a distinguished road
| More
Re: Basic Battle Game

Give Fighting.battlemethod() some arguments, e.g.
Code:
Fighting.battlemethod("xpi0t0s","whitfox",MAXINT);
C# uses function overloading, which means you can have multiple functions named battlemethod(), but they must have different argument lists, for example you could have the battlemethod defined above for a player, a monster and damage points; you could also have one for traps where a player just gets hit with a number of points, you can have one with no agruments at all that does whatever seems appropriate etc. So the other possibility is to define Fighting::battlemethod(/*no arguments*/).
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic C++ Resources shabbir C++ Programming 0 09-09-2006 05:17 AM
Basic C resources shabbir C Programming 0 09-09-2006 05:13 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 03:41 PM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board