FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Examples/Example1/RectangleExample/Rectangle.cs at master · TheGer/Examples · GitHub
TheGer
/
Examples
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
2
Code
Issues
0
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Examples
/
Example1
/
RectangleExample
/
Rectangle.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
97 lines (82 loc) · 1.9 KB
Breadcrumbs
Examples
/
Example1
/
RectangleExample
/
Rectangle.cs
Copy path
File metadata and controls
97 lines (82 loc) · 1.9 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Linq
;
using
System
.
Text
;
using
System
.
Threading
.
Tasks
;
namespace
RectangleExample
{
class
Rectangle
{
//attribute
int
width
;
//method which accesses the attribute
public
int
Width
{
get
{
return
width
;
}
set
{
if
(
value
>
0
)
{
width
=
value
;
}
}
}
//attribute
int
height
;
public
int
Height
{
get
{
return
height
;
}
set
{
if
(
value
>
0
)
{
height
=
value
;
}
}
}
public
Rectangle
(
)
{
width
=
0
;
height
=
0
;
}
public
Rectangle
(
int
w
,
int
h
)
{
Width
=
w
;
Height
=
h
;
}
public
int
area
(
)
{
return
width
*
height
;
}
public
int
perimeter
(
)
{
return
(
width
+
height
)
*
2
;
}
public
string
drawMe
(
)
{
string
output
=
""
;
for
(
int
r
=
1
;
r
<=
height
;
r
++
)
{
for
(
int
c
=
1
;
c
<=
width
;
c
++
)
{
if
(
(
r
==
1
)
||
(
r
==
height
)
)
{
output
+=
"X"
;
}
else
{
if
(
(
c
==
1
)
||
(
c
==
width
)
)
{
output
+=
"X"
;
}
else
{
output
+=
" "
;
}
}
}
output
+=
"
\n
"
;
}
return
output
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL