static void Main(string[] args) { Console.OutputEncoding = System.Text.Encoding.UTF8; ClassCompany company = new ClassCompany(); company.AskData(); Console.WriteLine(); company.ShowCompanyInfo(); company.Profit(company); Console.WriteLine(); ClassCompany company2 = new ClassCompany(); company2.AskData(); Console.WriteLine(); company2.ShowCompanyInfo(); company2.Profit(company2); Console.WriteLine(); ClassCompany company3 = new ClassCompany(); company3.AskData(); Console.WriteLine(); company3.ShowCompanyInfo(); company3.Profit(company3); Console.WriteLine(); Console.ReadKey(); }
//Copy constructor public ClassCompany(ClassCompany previousClassCompany) { Title = previousClassCompany.Title; Address = previousClassCompany.Address; this.Phone = previousClassCompany.Phone; this._outcome = previousClassCompany._outcome; this._expense = previousClassCompany._expense; }
public void Profit(ClassCompany previousClassCompany) { double profit = (previousClassCompany._outcome - previousClassCompany._expense) / previousClassCompany._expense * 100; if (profit < 100) { Console.WriteLine($"Yrityksellä {previousClassCompany.Title} menee heikosti. Voitto on alle 100% suurempi kuin menot!"); } else if (profit >= 100 && profit <= 300) { Console.WriteLine($"Yrityksellä {previousClassCompany.Title} menee tyydyttävästi. Voitto on 100% tai yli, mutta alle 300% suurempi kuin menot!"); } else { Console.WriteLine($"Yrityksellä {previousClassCompany.Title} menee loistavasti. Voitto on yli 300% suurempi kuin menot!"); } }