/**
* User can use methods to call on constructors
* to build various shapes and change colours.
* Interger methods are also explored.
*
*
* @Gregory Yates
*
*
*/
public class MyPicture
{
private Square square1;
private Square square2;
private Square square3;
private Square square4;
private Circle circle1;
private Triangle triangle1;
/**
* Constructor for objects of class MyPicture
*
*/
/**
* Creates a default circle(look at circle class for its state)
* Creates a square and triangle (look at both shapes classes for info on state)
*
*/
public MyPicture()
{
circle1 = new Circle();
circle1.changeColor("yellow");
circle1.makeVisible();
square1 = new Square(110, 60, 90, "red");
square2 = new Square(30, 70, 110, "blue");
square3= new Square( 30, 120, 105, "blue");
triangle1 = new Triangle(50, 150, 114, 40, "green");
}
/**
* creates a one Window House, using the square and triangle states to form a picture.
*/
public void createOneWindowHouse(){
square1 = new Square(110, 60, 90, "red");
square2 = new Square(30, 70, 110, "blue");
triangle1 = new Triangle(50, 150, 114, 40, "green");
square1.makeVisible();
square2.makeVisible();
triangle1.makeVisible();
}
/**
* Creates a two window house method, allowing the user to alternate between different
* settings. Adding a new square shape to act as a window.
*/
public void createTwoWindowHouse(){
square1 = new Square(110, 60, 90, "red");
square2= new Square(30, 70, 110, "blue");
square3= new Square(30, 120, 105, "blue");
triangle1= new Triangle(50, 150, 114, 40, "green");
square1.makeVisible();
square2.makeVisible();
square3.makeVisible();
triangle1.makeVisible();
}
/*
* Allows the user to change the triangle (roof) color
*
*/
public void changeRoofColour(String color){
triangle1.changeColor(color);
}
/*
* Adds a brilliant looking porch to the house, using a new Square shape.
*/
public void createPorch(){
square4 = new Square(40, 160, 150, "red");
square4.makeVisible();
}
/*
* A interger choice
* One Window House picture is assigned to "1"
* Two Window House picture is assigned to "2"
* If user enters any number lower then 1 or higher then 2, a error message is called.
*/
public void chooseAHouse(int choice){
if (choice == 1){
createOneWindowHouse();
}
if (choice == 2){
createTwoWindowHouse();
}
if ((choice < 1) || (choice > 2)){
System.out.println("Error! input must be either 1 or 2");
}
}
/*
* Users can change triangle color(roof color) selecting a interger
* red is assigned to 1
* blue is assigned to 2
* magenta is assigned to 3
* black is assigned to 4
* yellow is assigned to 5
* green is assigned to 6
*/
public void changeRoofColor (int choice){
if (choice == 1){
triangle1.changeColor("red");
}
if (choice == 2){
triangle1.changeColor("blue");
}
if (choice == 3){
triangle1.changeColor("magenta");
}
if (choice == 4){
triangle1.changeColor("black");
}
if (choice == 5){
triangle1.changeColor("yellow");
}
if (choice == 6){
triangle1.changeColor("green");
}
}
}