ערכתי לאחרונה בתאריך 19.05.10 בשעה 13:39 בברכה, eladmi
אני מנסה ליצור מופע של City אבל זה אומר שאין c'ntor שמקבל 0 ארגיומנטס.
Error 1 'exAPI.City' does not contain a constructor that takes '0' arguments O:\Documents\Documents\MCPD\HW\exAPI\exAPI\City.cs 159 22 exAPI
ויש לי אחד כזה וגם אחד שמקבל 7.
מה יכולה להיות הבעיה?
public City newCity(string newCityName, int dX, int dY) { City c = new City(); כאן יש בעיה c.cityName = newCityName; c.cityCenter.Move(dX, dY); c.centralStation.Move(dX, dY); c.numOfResidents = DEFAULT_VALUE_ZERO; c.noOfNeighborhoods = DEFAULT_VALUE_ONE; return c; } public City(string cityName, int cityCenterX, int cityCenterY, int centralStationX, int centralStationY, long numOfResidents, int noOfNeighborhoods) { this.CityName = cityName; Point p1 = new Point(cityCenterX, cityCenterY); this.CityCenter = p1; Point p2 = new Point (centralStationX, centralStationY); this.CentralStation = p2; this.NoOfNeighborhoods = noOfNeighborhoods; this.NumOfResidents = numOfResidents; //Here, instead adding else after the if, it will be more efficient to assign the value and then chek if it is correct. if (noOfNeighborhoods <= DEFAULT_VALUE_ZERO) { this.noOfNeighborhoods = DEFAULT_VALUE_ONE; } if (numOfResidents < DEFAULT_VALUE_ZERO) { this.numOfResidents = DEFAULT_VALUE_ZERO; } } public City(City other) { this.CityName = other.cityName; this.CityCenter = other.cityCenter; this.CentralStation = other.centralStation; this.NumOfResidents = other.numOfResidents; this.NoOfNeighborhoods = other.noOfNeighborhoods; }
|
האם אני חייב לרשום משהו כזה?
return new City(newCityName, dX, dY, dX, dY, 450, 10);
|
תודה רבה לעוזרים!!!!
THE Joker