using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CarCollection
{
public class Car
{
& private string model;
& private string company;
& private double price;
& public Car() {
&
& }
& //Constructor
& public Car(string model, string company, double price)
& {
this.model = model;
this.company = company;
this.price = price;
& }
& public string GetModel()
& {
return model;
& }
& public string GetCompany()
& {
return company;
& }
& public double GetPrice()
& {
return price;
& }
}
}
//Programm
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CarCollection
{
class Program
{
& static void Main(string[] args)
& {
List<Car> carcollection = new List<Car>();
Car c1, c2, c3, c4, c5;
c1 = new Car("Ferary", "Ferary", 100);
c2 = new Car("Honda", "Honda", 500);
c3 = new Car("Mersedes", "Mersedes", 600);
c4 = new Car("Ford", "Ford", 700);
c5 = new Car("Mitsubishi", "Mitsubishi", 900);
carcollection.Add(c1);
carcollection.Add(c2);
carcollection.Add(c3);
carcollection.Add(c4);
carcollection.Add(c5);
Console.WriteLine("Model Company Price");
for (int i = 0; i < 5; i++)
{
Console.WriteLine(carcollection[i].GetModel() + "& quot; + carcollection[i].GetCompany() + "& quot; + carcollection[i].GetPrice().ToString());
}
Console.ReadLine();
& }
}
}
Comments
Leave a comment