c#程序设计教程(李春葆第三版)第五章课后程序题答案

本文提供C#程序设计教程(李春葆第三版)第五章的四道课后练习题的代码实现,包括Person和Animal类的继承、委托与匿名方法的应用、动态数组管理和冒泡排序算法的实现。
摘要由CSDN通过智能技术生成

exci5-1

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

namespace exci5_1
{
class Program
{
static void Main(string[] args)
{
Person p1 = new Person(2, 50);
Animal a1 = new Animal(4,120);
p1.show();
a1.show();
}
}
public class Person //定义人类
{
public int legs; //腿的只数
protected float weight; //重量
public Person() //默认构造函数
{ }
public Person(int legs1, float weight1)//自定义方法F
{
legs = legs1;
weight = weight1;
}
public void show()
{
Console.WriteLine(“某人有{0}只腿,重量为{1}kg”, legs, weight);
}
}
class Animal //定义动物类
{
public int num; //腿的条数
private float weight; //重量
public Animal() //Animal类的默认构造函数
{ }
public A

  • 9
    点赞
  • 46
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值