variables - No overload for method 'zwierze' takes 0 arguments c# -
i haven't errors, program generates 0 animalage. should generate numbers 1-20. simple game player should find age of animal. corrected, still 0.
public class losowaniez { public int animalage; public static random animalage1 = new random(); public int age2 { { return animalage1.next(20); } } } public class animal { public void fish() { console.writeline("zwierze moze miec maksymalnie 10 lat, zgadnij ile ma lat"); int x = convert.toint32(console.readline()); } public int zwierze(losowaniez c) { int animalage = c.age2; console.writeline("zwierze moze miec maksymalnie 20 lat zgadnij ile ma lat"); int x = convert.toint32(console.readline()); if (x == animalage) { console.writeline("wygrales gre"); console.readkey(); } else if (x > animalage) { console.writeline("celuj nizej!"); zwierze(); } else { console.writeline("celuj wyzej!"); zwierze(); } } }
add constructor class losowaniez , assigning of age2 in constructor.
your class be
public class losowaniez { public int animalage; public int age2; public losowaniez() { int animalage; random randomobj = new random(); animalage = randomobj.next(20); age2 = animalage; } }
Comments
Post a Comment