Hi all! I'm very new to java coding, and I was assigned the task of making a house using the shapes folder example in BlueJ. My code is meant to use four square shapes, a triangle and a circle to form a house. However, the problem that I'm having is that when I try to create the house (both one and two window variants), only the roof (triangle) and the sun (circle) show. It's beyond my understanding just what has gone wrong, though I'm sure it's something simple that I'm overlooking.
If anybody can help me with this I'd be very grateful. Thanks in advance!If anybody can help me with this I'd be very grateful. Thanks in advance!Code:/** * MyPicture class has as attributes a number of shapes * and uses them to create pictures * * Name * Date */ public class MyPicture { private Square Square1; private Square Square2; private Square Square3; private Square Square4; private Circle Circle1; private Triangle Triangle1; /** * Instantiates a new MyPicture object. This is a default constructor * that only gives values to one of the object's attributes - a circle * which is given the colour yellow and made visible. * The other attributes are set to NULL. */ public MyPicture() { Circle1 = new Circle(); Circle1.changeColor("yellow"); Circle1.makeVisible(); } /** * A basic, one windowed house is created, consisting of two squares and triangles * which assigned integer values and then individually set to be visible. */public void createOneWindowHouse(){ Square1 = new Square(110, 60, 90, "red"); //Creates 'square1' Square2 = new Square(30, 70, 110, "black"); //Creates 'square2' Triangle1 = new Triangle(50, 150, 114, 40, "yellow"); //Creates 'triangle1' Square1.makeVisible(); //Enables visibility for 'square1' Square2.makeVisible(); //Enables visibility for 'square2' Triangle1.makeVisible(); //Enables visibility for 'triangle1' } /** * A varied version of the one windowed house is created, which creates a new square located * to the right of the first square in order to create a two windowed house. */public void createTwoWindowHouse(){ Square1 = new Square(110, 60, 90, "red"); //Creates 'square1' Square2 = new Square(30, 70, 110, "black"); //Creates 'square2' Square3 = new Square(30, 115, 110,"black"); //Creates 'square3' Square4 = new Square(12, 60, 60, "black"); //Creates 'square4' Triangle1 = new Triangle(50, 150, 114, 40, "yellow"); //Creates 'triangle1' Square1.makeVisible(); //Enables visibility for 'square1' Square2.makeVisible(); //Enables visibility for 'square2' Square3.makeVisible(); //Enables visibility for 'square3' Triangle1.makeVisible(); //Enables visibility for 'triangle1' } /** * This allows the user to select the colour of the porch. */public void changePorchColour(String colour){ Square4.changeColor(colour); //Changes the colour of square4, which represents the porch. } /** * Depending on which value that users input, a one or two windowed house is created. */public void chooseAHouse(int choice){ if (choice==1){ createOneWindowHouse(); //When the chosen value is 1, this method is performed } else if (choice==2) { createTwoWindowHouse(); //When the chosen value is 2, this method is performed } else if (choice!=1 && choice!=2){ System.out.println("ERROR! input must be either 1 or 2"); // If value is not equal to choice 1 or choice 2, the error message is displayed. } } /** * This changes the colour of the roof by selecting valid colours (e.g. "blue", "red", "green"). */public void changeRoofColour(String colour){ Triangle1.changeColor(colour); //Changes the colour of the triangle which was used to create the roof } /** * This changes the colour of the roof by entering a valid number from 1-6. * (e.g. 1 = black, 6= white) * If the input is an invalid number, an error message is displayed. */public void changeRoofColour2(int choice){ if (choice==1){ Triangle1.changeColor("black"); } else if (choice==2){ Triangle1.changeColor("red"); } else if (choice==3){ Triangle1.changeColor("blue"); } else if (choice==4){ Triangle1.changeColor("yellow"); } else if (choice==5){ Triangle1.changeColor("green"); } else if (choice==6){ Triangle1.changeColor("white"); } else{ System.out.println("ERROR! input must be between 1 and 6"); } } }