Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

‫ איתי גליק‬/‫משימות הגשה‬

2 ‫שאלה‬
class Actor

;private string id

;private string gender

;private int numFilms

public Actor(string id, string gender, int numFilms)

;this.id = id

;this.gender = gender

;this.numFilms = numFilms

)(public void addFilms

;this.numFilms += 1

public int Compare(Actor other)

if (other.numFilms < this.numFilms)

;return 1

else if (other.numFilms > this.numFilms)

;return 2

else

;return 3

)(public int getnum

;return this.numFilms

}
}

class Program

static void Main(string[] args)

;Actor ya = new Actor("123", "M", 7)

;Actor ya1 = new Actor("123", "M", 9)

;Actor ya2 = new Actor("123", "M", 10)

;Actor[] arr = new Actor [3]

;arr[0] = ya

;arr[1] = ya1

;arr[2] = ya2

;int num = 6

;int count = 0

for (int i=0;i<arr.Length;i++)

if(arr[i].getnum()> num)

;count += 1

}
}

;Console.WriteLine(count)

}
}
}
3 ‫שאלה‬
class flashlight

;string model

;Double price

public flashlight(string model, Double price)

;this.model = model

;this.price = price

)(public Double GetPrice

;return price

)(public string GetModel

;return model

class Program

public static void TwoFlashlight(flashlight[] arr, int total)

for (int i = 0; i < arr.Length; i++)

for (int j = i + 1; j < arr.Length; j++)

{
if (arr[i].GetPrice() + arr[j].GetPrice() == total)

;Console.WriteLine(arr[i].GetModel() + ", " + arr[j].GetModel())

}
}
}
}

public static void ThreeFlashlight(flashlight[] arr, int total)

for (int i = 0; i < arr.Length; i++)

for (int j = i + 1; j < arr.Length; j++)

for (int k = j + 1; k < arr.Length; k++)

if (arr[i].GetPrice() + arr[j].GetPrice() + arr[k].GetPrice() == total)

Console.WriteLine(arr[i].GetModel()+", "+ arr[j].GetModel()+", "+


;arr[k].GetModel())

}
}
}
}
}

static void Main(string[] args)

;flashlight f1 = new flashlight("inbar", 1)

;flashlight f2 = new flashlight("itay", 2)

;flashlight f3 = new flashlight("yuval", 3)


;flashlight f4 = new flashlight("ella", 4)

;flashlight f5 = new flashlight("roy", 5)

;flashlight[] arr = new flashlight[] { f1, f2, f3, f4, f5 }

;ThreeFlashlight(arr, 6)

}
}

You might also like