Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Desafio: Métodos | Introdução à Programação Orientada a Objetos (POO)
C# Além do Básico

bookDesafio: Métodos

Preencha as lacunas para criar um método que calcula a área de um círculo e retorna o valor.

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. O método retorna um valor double.
  2. Certifique-se de que o método utiliza a palavra-chave public.
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()}"); } }
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 8

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

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

bookDesafio: Métodos

Deslize para mostrar o menu

Preencha as lacunas para criar um método que calcula a área de um círculo e retorna o valor.

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. O método retorna um valor double.
  2. Certifique-se de que o método utiliza a palavra-chave public.
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()}"); } }
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 8
some-alt