방치하기

홍대 자바 수업 원주 ,넓이 구하는거-C# 생성자 사용 .. 본문

프로그래밍/C#

홍대 자바 수업 원주 ,넓이 구하는거-C# 생성자 사용 ..

Yi Junho 2009. 7. 20. 16:10
반응형
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication1
{
    class CirTest
    {
        private double r;
        double temp;
 
        public CirTest(double a)
        {
            this.r = a;
        }
        public double setR(double a)
        {
            r = a;
            return r;
        }
        public double rCal()
        {
            temp = r * 6.28;
            return temp;
        }
 
        public double r2Cal()
        {
            temp = r * r * 3.14;
            return temp;
        }
 
    }
 
 
    class Circle
    {
        public static void Main(String[] args)
    {
       CirTest jh=new CirTest(10);
      
       Console.WriteLine("넓이는"+jh.r2Cal());
       Console.WriteLine("원주는"+jh.rCal());
    }
    }
 
}
반응형
Comments