Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Uitdaging: Methoden | Introductie tot Objectgeoriënteerd Programmeren (OOP)
C# Verder dan de Basis

bookUitdaging: Methoden

Vul de ontbrekende delen in om een methode te maken die de oppervlakte van een cirkel berekent en de waarde retourneert.

index.cs

index.cs

copy
123456789101112131415161718192021222324252627282930313233
using 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()}"); } }
  1. De methode retourneert een double waarde.
  2. Zorg ervoor dat de methode het sleutelwoord public gebruikt.
index.cs

index.cs

copy
123456789101112131415161718192021222324252627282930313233
using 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?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 8

Vraag AI

expand

Vraag AI

ChatGPT

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

bookUitdaging: 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

index.cs

copy
123456789101112131415161718192021222324252627282930313233
using 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()}"); } }
  1. De methode retourneert een double waarde.
  2. Zorg ervoor dat de methode het sleutelwoord public gebruikt.
index.cs

index.cs

copy
123456789101112131415161718192021222324252627282930313233
using 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?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 8
some-alt