blikk info infothek forum galerie sitemap

Lösung von Objekte und Klassen

zur Aufgabenstellung

Basisklasse


public class Circle {

 

        public double x,y;     

        public double r;

        public double circumference(){    

                return 2*Math.PI*r;

        }

       

        public double area(){           

                return Math.PI*r*r;

        }

}

 

Testklasse


public class CircleTest {


        public static void main(String[] args) {

       

                Circle c;

                c = new Circle();

               

                c.x = 2.0;

                c.y = 2.0;

                c.r = 1.0;

               

                double a = c.area();

               

                System.out.println(a);

                System.out.println(c.circumference());

 

 

        }

 

}

 

Erstellt von Braun Daniel

nach oben