using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 模拟汽车奔跑{ class PRogram { static void Main(string[] args) { Car car = new Car(); car.name = "奔驰"; car.color = "红"; car.Address = "德国"; car.Run(); Car b = new Car("宝马","银灰","德国"); b.Run(); b.Run(200); Console.ReadLine(); } }}using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Collections;namespace 模拟汽车奔跑{ class Car { public string name{get;set;} public string color { get; set; } public string Address { get; set; } public Car (){ } public Car(string n,string c,string a) { this.name=n; this.color = c; this.Address = a; } public void Run() { Console.WriteLine("我是一辆{0}车,颜色是{1}色,产地在{2}!", this.name, this.color, this.Address); } public void Run(int speed) { Console.WriteLine("我是一辆{0}车,颜色是{1}色,产地在{2},最高车速{3}!", this.name, this.color, this.Address, speed.ToString()); } }}
新闻热点
疑难解答