Untitled

mail@pastecode.io avatar
unknown
plain_text
23 days ago
1.6 kB
2
Indexable
Never
using System;

class Car
{
    private string Company;
    private string Model;
    private int Year;

    public Car(string Company, string Model, int Year)
    {
        this.Company = Company;
        this.Model = Model;
        this.Year = Year;
    }

    public string getCompany() { return this.Company; }

    public string getModel() { return this.Model; }

    public int getYear() { return this.Year; }

    public Car copy(Car other)
    {
        Car new1 = new Car(other.getCompany(), other.getModel(), other.getYear());
        return new1;

    }

    public bool Equals(Car other)
    {
        if (this.Company == other.getCompany() && this.Model == other.getModel() && this.Year == other.getYear())
        {
            return true;
        }
        else
        {
            return false;
        }
    }


    public bool check()
    {
        if (this.Year > 2018)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    public override string ToString()
    {
        return "Car{" +
               "company=" + this.Company +
               "model=" + this.Model+
               "year=" + this.Year +
               "}";
    }
}


public class HelloWorld
{
    public static void Main(string[] args)
    {
        Car c1 = new Car("shay", "shay++", 2000);
        Car c2 = new Car("shay", "shay++", 2000);
        Car c3 = c2.copy(c2);
        Console.WriteLine(c1.Equals(c3)); 
        Console.WriteLine(c1.check()); 




    }
}
Leave a Comment