c#编程题!!!

1、编写一个rectangle(长方形)类,具体要求如下:
1) 它具有私有数据成员width(宽度)、height(高度)、L(周长)和S(面积);
2) 设置一个构造函数,用于在创建rectangle对象时,初始化该对象的长度和宽度;
3) 设置求长方体面积的方法eara( ),求周长的方法perimeter( ),输出面积和周长结果的方法showInfo( );
4) 最后创建一个rectangle类的实例对象,长度设置为10,宽度设置为5,并输出该对象的面积和周长。
2、编写父类小,提供私有属性:name,ownerName、 age,color,weight(体重),方法show 、playWithOwner。编写子类MyDog,子类中的属性沿用父类中的属性,并提供子类属性species(类别)。
3、编写一个student(学生)类,具体要求如下:
1) 它具有私有数据成员name(学生姓名)、grade(分数)和静态变量total(总分);
2) 设置一个构造函数,用于在创建student对象时,初始化该对象的姓名和分数;
3) 创建并初始化5位学生对象;
4) 使用静态成员计算这5位学生的总分以及平均分。
4、冒泡排序法

第一题:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace _1
{
    class rectangle
    {
        private double width, height, S, L;
 
        public rectangle(double w, double h)
        {
            width = w;
            height = h;
            double S = width * height;
            double L = 2 * (width + height);
        } 
         public double w{get;set;}
         public double h{ get; set;}
 
        public double GetArea()
        {
         
            return width * height;
        }
     
        public double GetPerimeter()
        {
            return 2 * (width + height);
        }
        public string Showinfo()
        {
            return string.Format("矩形的面积为:{0},周长为:{1}", S, L);
        }
 
   class Program
        {
            static void Main(string[] args)
            {
                 rectangle rect1 = new rectangle(10, 5);
                 Console.WriteLine("矩形rect1的面积为:{0}", rect1.GetArea());
                 Console.WriteLine("矩形rect1的周长为:{0}", rect1.GetPerimeter());
                 Console.Read();
        }
            }
        }
    }

第四题:

protected int[] bubbleUp(int[] Array)
    {
        for (int i = 0; i < Array.Length; i++)
        {
            for (int j = i+1; j < Array.Length; j++)
            {
                if (Array[i] > Array[j])
                {
                    int temp=Array[i];
                    Array[i]=Array[j];
                    Array[j] = temp;
                }
            }
        }
        return Array;
    }

温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-01-22
你好,你的这个程序什么要呢?是控制台程序?还是桌面程序
相似回答