Yarden
Explore posts from servers✅ override and virtual
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewClass
{
public class Vehicle
{
private string brand;
private string model;
private string color;
private int year;
private int numOfWheels;
private Radio radio = new Radio();//Has-a
protected Vehicle(string brand, string model, string color, int year, int numberOfWheels)
{
this.brand = brand;
this.model = model;
this.color = color;
this.year = year;
this.numOfWheels = numberOfWheels;
}
public int NumberOfWheels
{
get { return numOfWheels; }
set { numOfWheels = value; }
}
protected string getBrand()
{
return brand;
}
protected void setBrand(string brand) => this.brand = brand;
protected string getModel()
{
return model;
}
protected void setModel(string model) => this.model = model;
public string Color
{
get { return this.color; }
set { this.color = value; }
}
public int Year
{
get { return year; }
set
{
this.year = value;
}
//get => year;
//set => year = value;
}
public void setRadioColor(string color) { radio.setColor(color); } public string getRadioColor() { return radio.getColor(); }
//public static void Main(string[] args) //{ // Vehicle vehicle = new Vehicle("1", "2", "3", 1, 2); // vehicle.numOfWheels = 10; // Console.WriteLine(vehicle.numOfWheels); // Console.ReadLine(); //} }
}
public void setRadioColor(string color) { radio.setColor(color); } public string getRadioColor() { return radio.getColor(); }
//public static void Main(string[] args) //{ // Vehicle vehicle = new Vehicle("1", "2", "3", 1, 2); // vehicle.numOfWheels = 10; // Console.WriteLine(vehicle.numOfWheels); // Console.ReadLine(); //} }
}
23 replies