.


:




:

































 

 

 

 


Triangle TwoDShape Style.




, , , . #: base, : -, ; -, , . base.

base , . :

__{_): base (_) { //

}

_ , . .

base , TwoDShape . , Width Height. Triangle.

// TwoDShape. using System;

// , class TwoDShape { double pri_width; double pri_height;

// TwoDShape. public TwoDShape(double w, double h) {

Width = w;

Height = h;

}

public double Width {

get { return pri_width; }

set { pri_width = value < 0? -value: value; }

}

public double Height {

get { return pri_height; }

set { pri_height = value < 0? -value: value; }

}

public void ShowDim() {

Console.WriteLine(" " +

Width + " " + Height);

}

}

// , TwoDShape. class Triangle: TwoDShape { string Style;

// .

public Triangle(string s, double w, double h): base(w, h) Style = s;

}

// , public double Area() {

return Width * Height / 2;

}

// , public void ShowStyleO {

Console.WriteLine(" " + Style);

}

}

class Shapes4 {

static void Main() {

Triangle tl = new Triangle("", 4.0, 4.0); Triangle t2 = new Triangle("", 8.0, 12.0); Console.WriteLine(" tl: "); tl.ShowStyle(); tl.ShowDim();

Console.WriteLine(" " + tl.AreaO);

Console.WriteLine();

Console.WriteLine(" t2: "); t2.ShowStyle(); t2.ShowDim();

Console.WriteLine(" " + t2.Area());

Triangle .

Public Triangle(

string s, double w, double h): base(w, h) {

Triangle () base w h. , , TwoDShape (), Width Height w h. Triangle, Style, . TwoDShape - . , TwoDShape , , .

base , , , . TwoDShape Triangle, , , .

// TwoDShape.

Using System;

class TwoDShape { double pri_width; double pri_height;

// , , public TwoDShape() {

Width = Height = 0.0;

}

// TwoDShape. public TwoDShape(double w, double h) {

Width = w;

Height = h;

}

// , public TwoDShape(double ) {

Width = Height = x;

}

'// , public double Width {

get { return pri_width; }

set { pri_width = value < 0? -value: value; }

}

public double Height {

get { return pri_height; }

set { pri_height = value < 0? -value: value; }

}

public void ShowDimO {

Console.WriteLine(" " +

Width + " " + Height);

}

}

// , TwoDShape. class Triangle: TwoDShape { string Style;

/* , .

, TwoDShape. */ public Triangle() {

Style = "null";

}

// , , public Triangle(

string s, double w, double h): base(w, h) {

Style = s;

}

// , public Triangle(double x): base(x) {

Style = "";

}

// , public double Area() {

return Width * Height / 2;

}

// , public void ShowStyleO {

Console.WriteLine(" " + Style);

}

}

class Shapes5 {

static void Main() {

Triangle tl = new Triangle();

Triangle t2 = new Triangle("", 8.0, 12.0);

Triangle t3 = new Triangle(4.0);

tl = t2;

Console.WriteLine(" tl: "); tl.ShowStyle(); tl.ShowDim();

Console.WriteLine(" " + tl.AreaO);

Console.WriteLine();

Console.WriteLine(" t2: "); t2.ShowStyle (); t2.ShowDim();

Console.WriteLine(" " + t2.Area());

Console.WriteLine();

Console.WriteLine(" t3: "); t3.ShowStyle(); t3.ShowDim();

Console.WriteLine(" " + t3.Area());

Console.WriteLine();

}

}





:


: 2016-12-03; !; : 510 |


:

:

.
==> ...

1527 - | 1459 -


© 2015-2024 lektsii.org - -

: 0.013 .