שאלון 899381 מדעי המחשב ב' קיץ תשע"ו 2015 שאלה מספ...
שאלון 899381 מדעי המחשב ב' קיץ תשע"ו 2015 שאלה מספר שלוש פתרון בשפת C#
שאלה 3 סעיף א' נבנה פעולה בונה
public TvProgram(int code, int day, bool isSport)
{
this.code= code;
this.day = day;
this.isSport = isSport;
}
סעיף ב' (1) - נבנה את כותרת המחלקה TvWeek ואת התכונות שלה:
public class TvWeek{
private TvProgram [] arrProg = new TvProgram[100]; // 0-99
private int current = 0;
}
סעיף ב' (2) פעולה המוסיפה תכנית
public void AddTvProgram(TvProgram program )
{
arrPro[current] = program;
current++;
}
סעיף ב' (3) ספירת כל תכניות הספורט שיש בשבוע
public int CountSport()
{
int counter=0;
for(int i=0; i<current ; i++)
if(arrProg[i].GetIsSport())
counter++;
return counter;
}