What’s wrong with my code?
looked different solutions, did not understand. There is no argument, “name” from “drone.drone.
class program
{
Static Void Main (String [] Args)
{
Vehicle drone = new drive ();
Vehicle Archer = New Archer ();
drone.displayInfo ();
Archer.DisplayInfo ();
Console.ReadKey ();
}
}
class vehicle.
{
Public String Name {Get; SET; }
Public String Weapon {Get; SET; }
Public int PowerScore {Get; SET; }
Public int ENGENEPOWER {Get; SET; }
Public int vehicleid {get; SET; }
Public Vehicle ()
{}
Public Virtual Void DisplayInfo () {}
}
Class Drone: Vehicle
{
Public Drone (String Name, Int Vehicleid, String Weapon, Int Powerscore, Int EngenePower)
{
Vehicleid = 001; name = "droncarrier"; Powerscore = 5000; weapon = "drone fuse"; engenepower = 540;
}
Public Override Void DisplayInfo ()
{
Console.WRITELINE (VEHICLEID + "WITH" + NAME + "HAS" + POWERSCORE + "AND CARRYS WEAPON" + WEAPON + "ENGINE" + ENGENEPOWER);
}
}
Class Archer: Vehicle
{
Public Archer (String Name, Int Vehicleid, String Weapon, Int PowerScore, Int EngenePower)
{
Vehicleid = 003; Name = "miniarcher"; Powerscore = 5000; weapon = "crossbow"; engeneepower = 430;
}
Public Override Void DisplayInfo ()
{
Console.WRITELINE (VEHICLEID + "WITH" + NAME + "HAS" + POWERSCORE + "AND CARRYS WEAPON" + WEAPON + "ENGINE" + ENGENEPOWER);
}
}
Answer 1, Authority 100%
Drone
and Archer
Constructors only with parameters, what and says the compiler. But there is no error about Name
in the given code.
prog.cs (5,25): Error CS1729: The Type `Drone ‘Does Not Contain A Construction That Takes`’ arguments
Prog.cs (26,12): (Location of the Symbol Related to Previous Error)
prog.cs (6,26): Error CS1729: The Type` Archer ‘Does Not Contain A Construction That Takes`’ arguments
Prog.cs (37,12): (Location of the Symbol Related to Previous Error)