Data Entry Logic
Coddy'nin C# Journey'sinin Mantık & Akış bölümünün bir parçası — ders 41 / 66.
Görev
KolayVeri yapımız hazır olduğuna göre, öğrenci puanlarını girmek ve güncellemek için mantık uygulayalım.
DataEntry adında bir sınıf oluşturun ve şu yöntemlere sahip olsun:
SetStudentScore(int[][] scoreGrid, int studentIndex, int assignmentIndex, int score): Belirli bir öğrenci ve ödev için puanı ayarlar eğer geçerliyse. Dönüş:- 0 başarılıysa
- -1 herhangi bir indeks sınırların dışındaysa
- -2 puan geçersizse
UpdateAllScores(int[][] scoreGrid, int[] studentIndices, int assignmentIndex, int score): Aynı ödevde birden fazla öğrenci için puanları günceller. Başarıyla güncellenen puanların sayısını döndürür.
Not: Puan geçerliliğini kontrol etmek için DataCollector sınıfındaki ValidateScore yöntemini kullanın.
Kendin dene
using System; // Bu satırı silmeyin
public class DataEntry
{
public static int SetStudentScore(int[][] scoreGrid, int studentIndex, int assignmentIndex, int score)
{
// Kodunuzu buraya yazın
}
public static int UpdateAllScores(int[][] scoreGrid, int[] studentIndices, int assignmentIndex, int score)
{
// Kodunuzu buraya yazın
}
}
// Required for testing - do not modify
public class DataCollector
{
public static int[][] CreateScoreGrid(int students, int assignments)
{
int[][] scoreGrid = new int[students][];
for (int i = 0; i < students; i++)
{
scoreGrid[i] = new int[assignments];
}
return scoreGrid;
}
public static bool ValidateScore(int score)
{
return score >= 0 && score <= 100;
}
public static int[][] PopulateWithDefaultValues(int[][] scoreGrid)
{
for (int i = 0; i < scoreGrid.Length; i++)
{
for (int j = 0; j < scoreGrid[i].Length; j++)
{
scoreGrid[i][j] = -1;
}
}
return scoreGrid;
}
}Mantık & Akış bölümündeki tüm dersler
1Multi-dimensional Arrays
2D Arrays BasicsDeclaring and Initializing 2DAccessing 2D Array ElementsNested Loops with 2D ArraysJagged ArraysCommon Matrix OperationsRecap - Multi-dimensional4Flow Control Techniques
Early ReturnsGuard ClausesJump Statements (goto)Break and ContinueFlatten Nested Conditionals7Logical Operators Advanced
Short-Circuit EvaluationConditional Logical OperatorsOperator PrecedenceRecap - Advanced Operators2Advanced Decision Making
Multiple ConditionsComplex Boolean LogicIf vs. Switch ComparisonNested Switch StatementsRecap - Advanced Decisions5Exception Handling
Try-Catch BasicsException TypesMultiple Catch BlocksWorking with FilesFinally BlockUsing vs. Try-FinallyCustom ExceptionsRecap - Error Handling8Data Analysis System
Data Collection SetupData Entry Logic3Loop Enhancements
Loop PerformanceIterating ComplexEach Loop TypeRefactoring LoopsRecap - Optimized Loops6Null Handling
Null Reference BasicsNullable Value TypesNull Checking PatternsDefensive ProgrammingRecap - Null Safety