private string[] application;
public SmartPhone(string newOwner, int newYear, double newPrice, int battery, string[] application)
this.application = application;
public SmartPhone(SmartPhone other)
this.owner = other.owner;
this.price = other.price;
this.battery = other.battery;
this.application = other.application;
public string[] GetApplication()
public void SetOwner(string owner)
public void SetPrice(double price)
public void SetYear(int year)
public void SetBattery(int battery)
public void AddApplication(string newApplication)
while (this.application[index] != null)
if (index < this.application.Length)
this.application[index] = newApplication;
public void RemoveApplication()
int index = this.application.Length - 1;
while (this.application[index] == null)
this.application[index] = null;
public override string ToString()
string smartphoneString = "Smartphone- \n" + "Owner = " + this.GetOwner() + "\n" + "year = " + this.GetYear() + "\n" + "price = " + this.GetPrice() + "\n" + " battery " + this.GetBattery() + "\n " + "Applications = \n";
while (this.application[index] != null)
smartphoneString += "Application #" + index + ": " + this.application[index] + "\n";
public static void Main()
string[] apps1 = {"youtube", "instagram", "Whatsapp", "Fortnite"};
SmartPhone s1 = new SmartPhone("itay", 2000, 2000, 10, apps1);
string[] apps2 = {"youtube", "instagram", "Whatsapp", "Fortnite"};
SmartPhone s2 = new SmartPhone("Tal", 2000, 2000, 100, apps2);
string[] apps3 = {"youtube", "instagram", "Whatsapp", "Fortnite"};
SmartPhone s3 = new SmartPhone("Idan", 1000, 2000, 100, apps3);
Console.WriteLine(s1 + "\n" + s2 + "\n" + s3);
SmartPhone[] smartphones = {s1, s2, s3};
for (int i = 0; i < smartphones.Length; i++)
double newPrice = 1.2 * smartphones[i].GetPrice();
smartphones[i].SetPrice(newPrice);
if (smartphones[i].GetBattery() < 30)
smartphones[i].SetBattery(100);
if (smartphones[i].GetPrice() > maxprice)
maxprice = smartphones[i].GetPrice();
else if (smartphones[i].GetPrice()<maxprice && smartphones[i].GetPrice()>silver)
silver = smartphones[i].GetPrice();
Console.WriteLine("the most expensive is " + smartphones[index] + "and the secind one is " + smartphones[index2]);
Console.WriteLine(smartphones[index]);
SmartPhone s4 = new SmartPhone(s1);
Console.WriteLine("enter new owner");
string newowner =Console.ReadLine();
Console.WriteLine(s1 + "\n" + s2 + "n" + s3);