Ufak bir komut satırı programı yaptım. Sınıfı oluşturdum. Özelliklerini ve metotlarını girdim. Bir tane nesne atamak istiyorum ama atayamıyorum. Kod editörüm (VSC) sınıfı görmüyor.
[CODE lang="csharp" title="Program.cs"]/*
Uygulama: Quiz
Kullanıcıya çeşitli sorular sorulur ve kullanıcı bunları cevaplar. Kullanıcının skoru hesaplanır ve son adımda bu skor gösterilir
*/
using System;
namespace Quiz
{
class Quiz
{
public Quiz(var question, var choises,var answers) { //Constructer
this.Question = question;
this.Choises = choises;
this.Answers = answers;
}
//Properties
private string[] Question;
private string[] Choises;
private string[] Answers;
private byte point = 0;
//Methods
private void showQuestion(byte i) {
Console.WriteLine($"Soru {i+1}: ");
Console.WriteLine(this.Questions);
}
private void showChoises() {
foreach (var item in Choises)
{
Console.Write(" "+item+",");
}
}
private void calculateScore(byte i) {
var a = Console.ReadLine();
if(a.ToLower == this.Answers.ToLower)
this.point++;
else
this.point--;
}
private void showScore() {
Console.WriteLine(this.point);
}
// Public Main Method
public void showQuiz() {
for (byte i = 0; i < Questions.Length; i++)
{
showQuestion(i);
showChoises();
calculateScore(i);
}
showScore();
}
}
}
class Program
{
static void Main(string[] args)
{
}
}[/CODE]
[CODE lang="csharp" title="Program.cs"]/*
Uygulama: Quiz
Kullanıcıya çeşitli sorular sorulur ve kullanıcı bunları cevaplar. Kullanıcının skoru hesaplanır ve son adımda bu skor gösterilir
*/
using System;
namespace Quiz
{
class Quiz
{
public Quiz(var question, var choises,var answers) { //Constructer
this.Question = question;
this.Choises = choises;
this.Answers = answers;
}
//Properties
private string[] Question;
private string[] Choises;
private string[] Answers;
private byte point = 0;
//Methods
private void showQuestion(byte i) {
Console.WriteLine($"Soru {i+1}: ");
Console.WriteLine(this.Questions);
}
private void showChoises() {
foreach (var item in Choises)
{
Console.Write(" "+item+",");
}
}
private void calculateScore(byte i) {
var a = Console.ReadLine();
if(a.ToLower == this.Answers.ToLower)
this.point++;
else
this.point--;
}
private void showScore() {
Console.WriteLine(this.point);
}
// Public Main Method
public void showQuiz() {
for (byte i = 0; i < Questions.Length; i++)
{
showQuestion(i);
showChoises();
calculateScore(i);
}
showScore();
}
}
}
class Program
{
static void Main(string[] args)
{
}
}[/CODE]
Son düzenleyen: Moderatör: