S2T40 in-depth. NET platform and C # programming simple answer 52017-4-6

Source: Internet
Author: User

public class Powwow
{

Name
private string name;
public string Name
{
get {return name;}
set {name = value;}
}

Health value

private int blood;

public int Blood

{

get {return blood;}

set {blood = value;}

}

Combat effectiveness

private int power;
public int Power
{
get {return power;}
set {power = value;}
}

Level

private int level;

public int Level

{

get {return level;}

set {level = value;}

}

A constructor that has a parameter

Public Powwow (String name,int power,int level)

{

This. name = name;

This. Blood = 10000;

This. Power = power;

This. level = level;

}

Non-parametric constructors

Public Powwow ()

{

THIS.name = "Master Wang";

This. Blood = 10000;

This. Power = 100;

This.level = 3;

}

Overloaded methods

Public Powwow (String Name,int blood,int power, int. level)

{

This. name = name;

This. Blood = Blood;

This. Power = power;

This. level = level;

}

}

--------------------------------------------------------------------------------------------------------------- -------------------------------------------

Class Program {

static void Main (string[] args)

{

Powwow pw = new Powwow ();

Console.WriteLine ("The sorcerer's name {0}, health is {1}, fighting capacity {2}, level {3}", PW. Name, PW. Blood, PW. Power, PW. level);

Powwow pw1=new powwow ("East Poison West Xu", 1000,2);

Console.WriteLine ("The sorcerer's name {0}, health is {1}, fighting capacity {2}, level {3}", Pw1. Name,pw1. Blood,pw1. Power,pw1. level);

Powwow pw2 = new Powwow ("Master Poison", 6000, 98, 1);

Console.WriteLine ("The sorcerer's name {0}, health is {1}, fighting capacity {2}, level {3}", Pw2. Name, Pw2. Blood, Pw2. Power, Pw2. level);

Console.ReadLine ();

}

}

S2T40 in-depth. NET platform and C # programming simple answer 52017-4-6

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.