⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unknown.txt

📁 c语言多个实用小程序,会有帮助的~ 自己瞎编的
💻 TXT
字号:
using System;
namespace dirtysalt
{
	public class Car//class of car,has attribute of 'weight' and 'speed'
	{
		private int weight;
		private int speed;
		public Car(int Weight,int Speed)
		{
			weight=Weight;
			speed=Speed;
		}
		public void setweight(int Weight)
		{
			weight=Weight;
		}
		public void setspeed(int Speed)
		{
			speed=Speed;
		}
		public int getspeed()
		{
			return speed;
		}
		public int getweight()
		{
			return weight;
		}
	};


	public class Sportcar:Car//inherit class of Car,has  attributes of 'weight','speed','color'
	{
		private string color;
		public  Sportcar(int Weight,int Speed,string Color):base(Weight,Speed)
		{
			setweight(Weight);
			setspeed(Speed);
			color=Color;
		}
		public void setcolor(string Color)
		{
			color=Color;
		}
		public string getcolor()
		{
			return color;
		}
		public static void Main()
		{
			Car car=new Car(100,100);
			Sportcar sportcar=new Sportcar(100,200,"blcak");//here has a problem
			Console.WriteLine("car's weight is "+car.getweight());
			Console.WriteLine("car's speed is "+car.getspeed());
			Console.WriteLine("sportcar's weight is "+sportcar.getweight());
			Console.WriteLine("sportcar's speed is "+sportcar.getspeed());
			Console.WriteLine("sportcar's speed is "+sportcar.getcolor());
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -