You are on page 1of 5

namespace book

{
public class Book
{
private string name;
private int year;
private bool permission;

public Book(string name, int year, bool permission)


{
this.name = name;
this.year = year;
this.permission = permission;
}
public string GetName()
{
return this.name;
}
public int GetYear()
{
return this.year;
}
public bool GetPermission()
{
return this.permission;
}
public void SetName(string name)
{
this.name = name;
}
public void setYear(int year)
{
this.year = year;
}
public void setPermission(bool permission)
{
this.permission = permission;
}

// ToString
public override string ToString()
{
return "name: " + this.name + " year: " + this.year + " permission: " + this.permission;
}
// 2000 ‫לקראת שנת הלימודים החדשה החליט הספרן להוציא מהספרייה ספרים שיצאו לאור לפני שנת‬
//‫וספרים שאין להם אישור של משרד החינוך‬.
public bool IsStay()
{
if (this.year < 2000 || this.permission == false)
return false;
else
{
return true;
}

}
}
public static void BooksNames(Book[] arr)

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

if (arr[i].IsStay() == false)

Console.WriteLine(arr[i].GetName());

}
public static int LineSum(int[,] arr, int line)
{
int sum = 0;
for (int i = 0; i < arr.GetLength(1); i++)
{
sum += arr[line, i];
}
return sum;
}

public static int ColSum(int[,] arr, int col)


{
int sum = 0;
for (int i = 0; i < arr.GetLength(0); i++)
{
sum += arr[i, col];
}
return sum;
}

public static bool Corners(int[,] arr)


{
int n, m;
n = arr.GetLength(1);
m = arr.GetLength(0);
int sum = arr[0, 0] + arr[0, n - 1] + arr[m - 1, 0] + arr[m - 1, n - 1];
int center = arr[m / 2, n / 2];
return sum == center;
}

You might also like