Uitdaging: Methoden
Vul de ontbrekende delen in om een methode te maken die de oppervlakte van een cirkel berekent en de waarde retourneert.
index.cs
123456789101112131415161718192021222324252627282930313233using System; public class ConsoleApp { class Point { public double x; public double y; } class Circle { public double radius; public Point center; ___ ___ ___() { // The formula is: pi . r . r // The value of pi is 3.14 // r is the radius ___ ___ * ___* radius; } } public static void Main(string[] args) { Point p = new Point(); p.x = 15; p.y = 15; Circle circle = new Circle(); circle.radius = 10; circle.center = p; Console.WriteLine($"Area of the circle with center at ({circle.center.x}, {circle.center.y}) and radius of {circle.radius} is {circle.area()}"); } }
- De methode retourneert een
double
waarde. - Zorg ervoor dat de methode het sleutelwoord
public
gebruikt.
index.cs
123456789101112131415161718192021222324252627282930313233using System; public class ConsoleApp { class Point { public double x; public double y; } class Circle { public double radius; public Point center; public double area() { // The formula is: pi . r . r // The value of pi is 3.14 // r is the radius return 3.14 * radius * radius; } } public static void Main(string[] args) { Point p = new Point(); p.x = 15; p.y = 15; Circle circle = new Circle(); circle.radius = 10; circle.center = p; Console.WriteLine($"Area of the circle with center at ({circle.center.x}, {circle.center.y}) and radius of {circle.radius} is {circle.area()}"); } }
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 3. Hoofdstuk 8
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Suggested prompts:
Can you give me a hint for filling in the blanks?
Can you show me the complete solution for the method?
Can you explain how to calculate the area of a circle?
Awesome!
Completion rate improved to 2.04
Uitdaging: Methoden
Veeg om het menu te tonen
Vul de ontbrekende delen in om een methode te maken die de oppervlakte van een cirkel berekent en de waarde retourneert.
index.cs
123456789101112131415161718192021222324252627282930313233using System; public class ConsoleApp { class Point { public double x; public double y; } class Circle { public double radius; public Point center; ___ ___ ___() { // The formula is: pi . r . r // The value of pi is 3.14 // r is the radius ___ ___ * ___* radius; } } public static void Main(string[] args) { Point p = new Point(); p.x = 15; p.y = 15; Circle circle = new Circle(); circle.radius = 10; circle.center = p; Console.WriteLine($"Area of the circle with center at ({circle.center.x}, {circle.center.y}) and radius of {circle.radius} is {circle.area()}"); } }
- De methode retourneert een
double
waarde. - Zorg ervoor dat de methode het sleutelwoord
public
gebruikt.
index.cs
123456789101112131415161718192021222324252627282930313233using System; public class ConsoleApp { class Point { public double x; public double y; } class Circle { public double radius; public Point center; public double area() { // The formula is: pi . r . r // The value of pi is 3.14 // r is the radius return 3.14 * radius * radius; } } public static void Main(string[] args) { Point p = new Point(); p.x = 15; p.y = 15; Circle circle = new Circle(); circle.radius = 10; circle.center = p; Console.WriteLine($"Area of the circle with center at ({circle.center.x}, {circle.center.y}) and radius of {circle.radius} is {circle.area()}"); } }
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 3. Hoofdstuk 8