Professional Documents
Culture Documents
אובייקטים
אובייקטים
1
)שעות (מספר שלם .א
)דקות (מספר שלם .ב
)שניות (מספר שלם .ג
.כתוב פעולות פנימית המקבלת כפרמטר קלט עבור משתנה מסוים ובודקת את תקינותו .4
.Set השתמש הפעולות שכתבת בסעיף הקודם בתוך הבנאי המלא ובפעולות ה .5
.HH:MM:SS :כתוב פעולה פנימית במחלקה המחזירה את המחרוזת המכילה את השעה הנוכחית בפורמט הבא .6
. לאחר קידום השניות יש לבדוק את הצורך לקדם גם את הדקות ואת השעות:שים לב
. וחוזרת על עצמה בלולאה אינסופית7 מפעילה את הפעולה של סעיף, ממתינה שניה אחת,6 כתוב תוכנה המציגה על המסך את הערך המוחזר מהפעולה של סעיף .9
.) המראים זמנים שוניםClock שעונים (אובייקטים מסוג10 צור מערך של .10
.) בערב6 בבוקר עד6 כתוב פעולה חיצונית המקבלת כפרמטר את מערך השעונים ומציגה על המסך את הזמנים של השעונים המראים שעה ביום (מ .11
namespace ConsoleApp8
{
class clock
{
;int hour
;int minutes
;int seconeds
public clock(int Hour, int Minutes, int Seconeds) { CheckHour(Hour); CheckMinutes(Minutes);
CheckSecondes(Seconeds);}
public clock() { hour = 0; minutes = 0; seconeds = 0;}
public int GetHour(){ return hour;}
public int GetMinutes(){ return minutes;}
public int GetSeconeds(){ return seconeds;}
public void SetHour(int Hour){ hour = Hour;}
public void SetMinutes(int Minutes){ minutes = Minutes;}
public void SetSeconeds(int Seconeds){ seconeds = Seconeds;}
public void CheckHour(int Hour){if (Hour <= 24 && Hour > 0)hour = Hour;}
public void CheckMinutes(int Minutes){if (Minutes < 60 && Minutes > 0)minutes = Minutes;}
public void CheckSecondes(int Secondes) { if (Secondes >= 0 && Secondes <= 60){seconeds = Secondes;}}
)(public string PrintFullHour
{
;"" = string FullHour
;"string HourUnites = "0
;"string MinutesUnites = "0
;"string SecondesUnites = "0
if(hour<10){HourUnites="0"+hour.ToString();}
if(minutes<10){MinutesUnites="0"+minutes.ToString();}
if(seconeds<10){SecondesUnites="0"+seconeds.ToString();}
if(hour<10&&minutes>10&&seconeds>=10){FullHour="the time is: "+HourUnites.ToString()
+":"+minutes.ToString()+":"+seconeds.ToString();}
if(minutes<10&&hour>10&&seconeds>=10){FullHour="the time is: "+hour.ToString()
+":"+MinutesUnites.ToString()+":"+seconeds.ToString();}
if(seconeds<10&&hour>10&&minutes>=10){FullHour="the time is "+hour.ToString()
+":"+minutes.ToString()+":"+SecondesUnites.ToString();}
if(hour<10&&minutes<10&&seconeds<10){FullHour="the time is: "+HourUnites.ToString()
+":"+MinutesUnites.ToString()+":"+SecondesUnites.ToString();}
if(hour>=10&&minutes<10&&seconeds<10){FullHour="the time is: "+hour.ToString()
+":"+MinutesUnites.ToString()+":"+SecondesUnites.ToString();}
if(hour<10&&minutes>=10&&seconeds<10){FullHour="the time is: "+HourUnites.ToString()
+":"+minutes.ToString()+":"+SecondesUnites.ToString();}
if(hour<10&&minutes<10&&seconeds>=10){FullHour="the time is: "+HourUnites.ToString()
+":"+MinutesUnites.ToString()+":"+seconeds.ToString();}
if(hour>=10&&minutes>=10&&seconeds>=10){ FullHour = "the time is "+hour.ToString()
+":"+minutes.ToString()+":"+seconeds.ToString();}
;Console.WriteLine(FullHour)
;return FullHour
}
)(public int AddSeconed
{
;++seconeds
if (seconeds == 60)
{
;seconeds = 0
;++minutes
if ( minutes == 60)
{
;++seconeds = 0; minutes = 0; hour
if (hour== 24)
{
;seconeds = 0; minutes = 0; hour = 0
}
}
}
;return seconeds;return minutes;return hour
}
}
internal class Program
{
static void Main(string[] args)
{
;clock c1 = new clock(40,40,40)
while (true) {c1.PrintFullHour(); Thread.Sleep(1000); ; c1.AddSeconed(); } //
;clock[] clocks = new clock[10]
;clocks[0]=new clock(0, 0, 0)
;clocks[1] = new clock(10, 10, 10)
;clocks[2] = new clock(21, 20, 20)
;clocks[3] = new clock(2,2,3)
;clocks[4] = new clock(3,3,3)
;clocks[5] = new clock(4,4,4)
;clocks[6] = new clock(5,5,5)
;clocks[7] = new clock(6,6,6)
;clocks[8] = new clock(7,7,7)
;clocks[9] = new clock(8,8,8)
;PrintClocks(clocks)
}
static void PrintClocks(clock[] clocks)
{
for (int i = 0; i < clocks.Length; i++)
{
if (clocks[i].GetHour()>=6&& clocks[i].GetHour()<=18)
{
;)(clocks[i].PrintFullHour
}
}
}
}
}
namespace ConsoleApp6
{
class Car
{
;string type
;int year
;int price
;double liters
;int km
)(public Car
{
;" type = "none
;year = 0
;price = 0
;liters = 0
;km = 0
}
public Car(string Type, int Year)
{
;type = Type
;year = Year
;price = 0
;liters = 0
;km = 0
}
public Car(string Type, int Year, int Price, double Liters, int Km)
{
;type = Type
;year = Year
;price = Price
;liters = Liters
;km = Km
}
{)(public void Print
};Console.Write(type+" "+year+" "+price+" "+liters+" "+km)
}
internal class Program
{
static void Main(string[] args)
{
;)(Car c1 = new Car
;Car c2 = new Car("men", 2006)
;Car c3 = new Car("honda", 2014, 700, 56.8, 200)
;)(EnterCar("a", 200, 8000, 70.5, 10).Print
}
static Car EnterCar(string Type, int Year, int Price, double Liters, int Km)
{
;Car UserCar = new Car(Type, Year, Price, Liters, Km)
;return UserCar
}
}
}
class Smartphone
{
;string name
;int size
;int storage
;int year
;int price
public Smartphone() { name = ""; size = -1; storage = -1; year = -1; price = -1; }
public Smartphone(string Name, int Size, int Storage, int Year, int Price)
} ;name = Name; CheckSize(Size); CheckStorage(Storage); CheckYear(Year); CheckPrice(Price) {
public void CheckSize(int Size) { if (Size > 0) size = Size; }
public void CheckStorage(int Storage) { if (Storage > 0) storage = Storage; }
public void CheckYear(int Year) { if (Year > 0) year = Year; }
public void CheckPrice(int Price) { if (Price > 0) price = Price; }
public string Getname() { return name; }
public int Getsize() { return size; }
public int Getstorage() { return storage; }
public int Getyear() { return year; }
public int Getprice() { return price; }
public void Print() { Console.WriteLine(name + " " + size + " " + storage + " " + year + " " + price); }
}
}
internal class Program
{
static void Main(string[] args)
{
;Smartphone[] phones = new Smartphone[5]
;phones[0] = new Smartphone("a", 10, 20, 30, 40)
;phones[1] = new Smartphone("b", 100, 200, 300, 400)
;phones[2] = new Smartphone("c", 12, 13, 45, 50)
;phones[3] = new Smartphone("d", 40, 50, 60, 70)
;phones[4] = new Smartphone("e", 17, 92, 78, 64)
;PriceBelow(70, phones)
;Sort(phones)
;newest(phones)
}
static void PriceBelow(int Price, Smartphone[] phones)
{
for (int i = 0; i < phones.Length; i++)
{
if (Price > phones[i].Getprice())
;)(phones[i].Print
}
}
static void Sort(Smartphone[] phones)
{
;Smartphone temp
for (int z = 0; z <= phones.Length - 2; z++)
{
for (int r = 0; r <= phones.Length - 2; r++)
{
if (phones[r].Getprice() < phones[r + 1].Getprice())
{
;temp = phones[r + 1]
;phones[r + 1] = phones[r]
;phones[r] = temp
}
}
}
foreach (Smartphone phone in phones) { Console.WriteLine(phone.Getprice()); }
}
static void newest(Smartphone[] phones)
{
;Smartphone temp2
for (int z = 0; z <= phones.Length - 2; z++)
{
for (int r = 0; r <= phones.Length - 2; r++)
{
if (phones[r].Getyear() < phones[r + 1].Getyear())
{
;temp2 = phones[r + 1]
;phones[r + 1] = phones[r]
;phones[r] = temp2
}
}
}
for (int i = 0; i < 3; i++)
}};Console.WriteLine(phones[i].Getyear()) {
: בעל המאפיינים הבאיםEvent צרו אובייקט בשם .1
.שם האירוע .a
.יום בחודש של האירוע .b
.חודש האירוע .c
.שנת האירוע .d
.הוסיפו לאובייקט בנאי ברירת מחדל ובנאי מלא הכולל מסננת קלט לכל התכונות .2
.הוסיפו את אותה מסננת הקלט גם לתכונות האובייקט שלא יקבלו ערך שגוי .3
. בעלי מאפיינים שוניםEvent אובייקטים מסוג5 צרו מערך של .4
הפעולה תציג על המסך שם האירוע או האירועים. חודש ושנה) ואת מערך האירועים,צרו פעולה המקבלת כפרמטר את תאריך האירוע המבוקש (יום .5
.המתוכננים ליום זה שמופיעים במערך
כך שבמקום הראשון במערך יופיע האירוע בעל תאריך, המקבלת כפרמטר את מערך האירועים וממיינת אותו לפי התאריך המלאSort צרו פעולה בשם .6
.קרוב ביותר/ישן
namespace ConsoleApp6
{
class Event
{
;string name
;int day
;int month
;int year
)(public Event
{
;" name = "none
;day = -1
;month = -1
;year = -1
}
public Event(string Name, int Day, int Month, int Year)
{
;name = Name
;CheckDay(Day)
;CheckMonth(Month)
;CheckYear(Year)
}
public string GetName() { return name; }
public int GetDay() { return day;}
public int GetMonth() { return month;}
public int GetYear() { return year;}
public void CheckDay(int Day) {if (Day>0&&Day<=32) {day = Day;}}
public void CheckMonth(int Month) { if(Month>0&&Month<=12){month = Month;}}
public void CheckYear(int Year) {if (Year > 2022) { year = Year;}}
}
internal class Program
{
static void Main(string[] args)
{