V
V
Vitalii Tytarchuk2021-06-15 19:57:32
Java
Vitalii Tytarchuk, 2021-06-15 19:57:32

How to pass values ​​from a constructor to a method?

public class Rectangle extends Shape{
    Rectangle(Double w, Double h)
    {
        super(dim -> dim[0] > 0 && dim[1] > 0, dim -> dim[0] * 2 + dim[1] * 2 ,dim -> dim[0] * dim[1],new Double[]{w, h});
    }
    
    static void DrawRectangle(   )
    {
       final String asterisk = "*";
       for(int i = 0; i <= w; i++)
       {
           for(int j = 0; j <= h; j++)
           {
               System.out.print(asterisk);
           }
           System.out.println();
       }
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question