Note that there are some explanatory texts on larger screens.

plurals
  1. POJava: Call a method inside a method and use the same variables
    primarykey
    data
    text
    <p>I have this code which uses an open source API (Sweethome3D). What I want to do is to check whether the Room is Parallelogram or Square and then call a method and change the values of the walls and the Room. But if I try to do this, it gives me error. Do you have any idea how I can do that?</p> <pre><code>@Override public Home createHome() { Home home = super.createHome(); if (Shape_of_Room.equals("Parallelogram")) { float[][] points = { { 0f, 0f }, { 0f, 400f }, { 625f, 400f }, { 625f, 400f }, { 625f, 0f }, { 0f, 0f } }; Room Parallelogram_Room = new Room(points); Parallelogram_Room.setAreaVisible(true); // Add new Room to Home home.addRoom(Parallelogram_Room); // Check for Ceiling and Floor Display if (Floor_Display.equals("true")) { Parallelogram_Room.setFloorVisible(true); } else if (Floor_Display.equals("false")) { Parallelogram_Room.setFloorVisible(false); } if (Ceiling_Display.equals("true")) { Parallelogram_Room.setCeilingVisible(true); } else if (Ceiling_Display.equals("false")) { Parallelogram_Room.setCeilingVisible(false); } Wall Left_Wall = new Wall(0, 0, 0, 400, (float) 7.62); Wall North_Wall = new Wall(0, 400, 625, 400, (float) 7.62); Wall Right_Wall = new Wall(625, 400, 625, 0, (float) 7.62); Wall South_Wall = new Wall(625, 0, 0, 0, (float) 7.62); Left_Wall.setWallAtEnd(North_Wall); North_Wall.setWallAtEnd(Right_Wall); Right_Wall.setWallAtEnd(South_Wall); South_Wall.setWallAtEnd(Left_Wall); // Check the color of the Walls // Values set from site // http://cloford.com/resources/colours/500col.htm // and by the calculator // http://www.shodor.org/stella2java/rgbint.html int k; String[] Color = { "Grey", "Red", "Green", "Blue", "Yellow", "White" }; int[] Color_Number = { 13882323, 16764108, 7456369, 13421823, 11394815, 16777215 }; for (k = 0; k &lt; 6; k++) { if (Left_Wall_Color.equals(Color[k])) { Left_Wall.setLeftSideColor(Color_Number[k]); } if (North_Wall_Color.equals(Color[k])) { North_Wall.setLeftSideColor(Color_Number[k]); } if (Right_Wall_Color.equals(Color[k])) { Right_Wall.setLeftSideColor(Color_Number[k]); } if (South_Wall_Color.equals(Color[k])) { South_Wall.setLeftSideColor(Color_Number[k]); } } // Check if the walls are Matt or Shiny if (Shiny_Matt.equals("Matt")) { Left_Wall.setLeftSideShininess(0); North_Wall.setLeftSideShininess(0); Right_Wall.setLeftSideShininess(0); South_Wall.setLeftSideShininess(0); } else if (Shiny_Matt.equals("Shiny")) { Left_Wall.setLeftSideShininess(1); North_Wall.setLeftSideShininess(1); Right_Wall.setLeftSideShininess(1); South_Wall.setLeftSideShininess(1); } home.addWall(Left_Wall); home.addWall(North_Wall); home.addWall(Right_Wall); home.addWall(South_Wall); } // Modify home as you wish here System.out.println("method called"); return home; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload