17复习

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _17复习
{
    class Program
    {
        static void Main(string[] args)
        {

            //Truck t = new Truck("解放牌","绿色",500);
            //t.Lahuo();
            //Car c = new Car("红旗","黑色",5);
            //c.Laren();

            //-----------------------------------------------------------------
            //定义的父类,赋的值是子类
            //Shape shape = new Circle(5);

            //double area = shape.GetArea();
            //double perimeter = shape.GetPerimeter();

            //Console.WriteLine("面积是{0:0.00},周长是{1:0.00}",area,perimeter);

            //Shape squ = new Square(4,3);
            //double are = squ.GetArea();
            //double per = squ.GetPerimeter();

            //Console.WriteLine("面积是{0:0.00},周长是{1:0.00}", are, per);

            //-----------------------------------------------------------------

            //接口实现多态,声明的是接口
            IBark bark = new RealDuck();
            bark.Bark();

        }
    }

    class Duck
    {
        public void Swim()
        {
            Console.WriteLine("鸭子都会游泳");
        }
    }

    interface IBark
    {
        void Bark();
    }

    class XPDuck : Duck, IBark
    {
        public void Bark()
        {
            Console.WriteLine("橡皮鸭唧唧叫");
        }
    }

    class RealDuck : Duck, IBark
    {
        public void Bark()
        {
            Console.WriteLine("真鸭子嘎嘎叫");
        }
    }

    class MuDuck : Duck
    {

    }

    //-----------------------------------------------------------------

    abstract class Shape
    {
        public abstract double GetArea();
        public abstract double GetPerimeter();
    }

    class Circle : Shape
    {
        public double R { get; set; }
        public Circle(double r)
        {
            this.R = r;
        }

        public override double GetArea()
        {
            return Math.PI * this.R * this.R;
        }

        public override double GetPerimeter()
        {
            return 2 * Math.PI * this.R;
        }
    }

    class Square : Shape
    {
        public double Height { get; set; }
        public double Width { get; set; }
        public Square(double height,double width)
        {
            this.Height = height;
            this.Width = width;
        }

        public override double GetArea()
        {
            return this.Height * this.Width;
        }

        public override double GetPerimeter()
        {
            return (this.Height + this.Width) * 2;
        }
    }

    //-------------------------------------------------------------------------------------------

    class Vehicle
    {
        public string Brand { get; set; }
        public string  Color { get; set; }
        public void Run()
        {
            Console.WriteLine("是车都能跑");
        }

        public Vehicle(string brand,string color)
        {
            this.Brand = brand;
            this.Color = color;
        }
    }

    class Truck : Vehicle
    {
        public double Weight { get; set; }
        public Truck(string brand,string color,double weight) : base(brand, color)
        {
            this.Weight = weight;
        }

        public void Lahuo()
        {
            Console.WriteLine("卡车可以拉{0}KG货",this.Weight);
        }
    }

    class Car :Vehicle
    {
        public int Passenger { get; set; }
        public Car(string brand,string color,int passenger) : base(brand, color)
        {
            this.Passenger = passenger;
        }

        public void Laren()
        {
            Console.WriteLine("轿车可以拉{0}人",this.Passenger);
        }
    }

    //-------------------------------------------------------------------------------------------
    class Father
    {
        public string LastName { get; set; }
        public double Property { get; set; }
        public string BloodType { get; set; }
        public Father(string lastName,double property,string bloodType)
        {
            this.LastName = lastName;
            this.Property = property;
            this.BloodType = bloodType;
        }
    }

    class Son : Father
    {
        //默认调用无参构造函数
        public Son(string lastName,double property,string bloodType):base(lastName,property,bloodType)
        {

        }

        public void PlayGame()
        {
            Console.WriteLine("儿子玩游戏");
        }
    }

    class Daughter : Father
    {
        public Daughter(string lastName,double property,string bloodType) : base(lastName, property, bloodType)
        {

        }

        public void Dance()
        {
            Console.WriteLine("女儿会跳舞");
        }
    }
}
时间: 2024-08-10 23:42:16

17复习的相关文章

7.17复习内容

# !/usr/bin/env python # !--*--coding:utf-8 --*-- # [email protected] :2018/7/17 20:32 # [email protected] TrueNewBee # 2018-7-17 20:57:16 # 复习: # 信号量 Semaphore # from multiprocessing import Semaphore # 用锁的原理实现的,内置了一个计数器 # 在同一时间,只能有指定数量的进程执行某一段被控制的代码

6.17 复习 根据学生分数进行学生信息的 冒泡排序

using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; namespace 复习CS { class Program { struct Student { public int num; public string Code; public string Name; public decimal Score; } static v

5 Jun 18 复习,模块

5 Jul 17 复习,内置模块与第三方模块 一.time与datetime import time # 时间戳(timestamp):通常来说,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量. print(time.time())  # 1528188733.8373 # 格式化的时间字符串(Format String) print(time.strftime("%Y-%m-%d %X"))  # 2018-06-05 16:52:13 # 结构化的时间(st

12 django_ajax

django_ajax AJAX(Asynchronous Javascript And XML)“异步Javascript和XML”.即使用Javascript语言与服务器进行异步交互,传输的数据为XML(现在更多使用json数据). 同步交互:客户端发出一个请求后,需要等待服务器响应结束后,才能发出第二个请求: 异步交互:客户端发出一个请求后,无需等待服务器响应结束,就可以发出第二个请求. AJAX除了异步的特点外,还有一个就是:浏览器页面局部刷新:(这一特点给用户的感受是在不知不觉中完成请

暑假集训结束

暑假集训结束了!!! 说实话其实还是有些遗憾的,我没有和同学一起去诸暨集训,但是我还是很高兴,我的同学将试题都发给了我,以至于我没有落后太多,所以这里致谢机房其他4位大佬. 我重新翻了一下我的做题记录,虽然做题不多,但是至少每道题都有收益,于是想要总结一下. 6.16 期末考试告一段落 6.17 复习了并查集,知道了并查集记录链头和链长的方法P1196 6.18 继续研究DP,加深了树形DP,学习了悬线法,用此方法解决了以前乱搞的题 6.19 复习状压DP 6.20 pb学哥来讲课了,然后学习了

AnimeGAN输出日志

D:\MyFiles\LearnFiles\Code\Python\AnimeGAN\AnimeGAN>python main.py --phase train --dataset Hayao --epoch 1 --init_epoch 1D:\Users\feng_\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\dtypes.py:516: FutureWarning:

2017.2.17 C语言复习笔记

<1> 格式说明由"%"和格式字符组成,如%d%f等.它的作用是将输出的数据转换为指定的格式输出.格式说明总是由"%"字符开始的.不同类型的数据用不同的格式字符. 格式字符有d,o,x,u,c,s,f,e,g等. 如 %d整型输出,%ld长整型输出, %o以八进制数形式输出整数, %x以十六进制数形式输出整数, %u以十进制数输出unsigned型数据(无符号数). %c用来输出一个字符, %s用来输出一个字符串, %f用来输出实数,以小数形式输出, %

2016.6.17 计算机网络复习要点之PPP协议

点对点协议PPP是目前使用最广泛的数据链路层协议. 1.PPP协议的特点: **我们知道因特网用户通常需要连接到某个ISP才能接入到因特网,PPP协议就是用计算机和ISP进行通信时所使用的数据链路层协议. (1)简单:接收方每收到一个帧,就进行CRC检验,如CRC检验正确,就收下这个帧:反之,就丢弃这个帧,其他什么也不做. (2)封装成帧:PPP协议必须规定特殊的字符作为帧定界符(即标志一个帧的开始和结束的字符),以便使接收端收到的比特流中能准确地找到帧开始和结束的位置. (3)透明性:PPP协

mysql复习篇及一对多和多对多的总结(17.6.26 )

一.疑问 1.varchar  与 char  区别 答:char 只能存储指定的字符长度,varchar存储的字符长度是可变动的 例子 char(10),varchar(10) ,10代表是字符长度是10,char表示只能存储10个字符大于10不存储小于10也按10个位置来,varchar,存入多少就按多少来. char优缺点:效率高,与varchar相比浪费内存. varchar优缺点: 节省空间,效率低. 2.select * from t1 where nid in (1,2,3)  代