I hafta make a house and I understand how to make 1 house with your drawing tool and stuff
Well this is how my code looks like:
(i understand that I have useless stuff)
So far, this code lets me make 1 house
I need a code that lets me make 3 houses next to each other
Can anyone help me by getting me on the right track or assisting me in a greater fashion
Thanks
Main:
import apcslib.*;
/**
* Write a description of class Main here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Main
{
public static void main(String[] args)
{
// create a Sketchpad that is 300 pixels by 300 pixels and
// a drawing tool
DrawingTool pen = new DrawingTool(new SketchPad(300,300));
// create the House object so that the lower left corner
// is at (-75,-75) within the SketchPad
int xStart = -75;
int yStart = -75;
int xStart1 = 25;
int yStart1 = -75;
int xStart2 = 125;
int yStart2 = -75;
House myHouse = new House(xStart, yStart);
House myHouse1 = new House(xStart1, yStart1);
House myHouse2 = new House(xStart2, yStart2);
// ask myHouse to draw itself using pen
myHouse.draw(pen);
myHouse1.draw(pen);
myHouse2.draw(pen);
/* myHouse.draw1(pen);
myHouse.draw2(pen); */
}
}
House Class:
import apcslib.*;
/**
* Write a description of class House here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class House
{
// instance variables - replace the example below with your own
private int myX;
private int myY;
private int myx1;
private int myy1;
private int myx2;
private int myy2;
/**
* Constructor for objects of class House
*/
public House(int x, int y)
{
// initialise instance variables
myX = -75;
myY = -75;
}
public void draw(DrawingTool aPen)
{
// instructions for drawing a house
aPen.up ();
aPen.move (myX, myY);
aPen.down ();
aPen.move (myX,myY+50);
aPen.move (myX+100,myY+50);
aPen.move (myX+100,myY);
aPen.move (myX,myY);
aPen.up ();
aPen.move (myX,myY+50);
aPen.down ();
aPen.move (myX+50, myY+75);
aPen.move (myX+100, myY+50);
aPen.up ();
aPen.move (myX+20,myY+20);
aPen.down ();
aPen.drawRect (20,20);
aPen.up ();
aPen.move (myX+80, myY+20);
aPen.down ();
aPen.drawRect (20,20);
aPen.up ();
aPen.move (myX+40, myY);
aPen.down ();
aPen.move (myX+40, myY+30);
aPen.move (myX+60, myY+30);
aPen.move (myX+60, myY);
}
}
Well this is how my code looks like:
(i understand that I have useless stuff)
So far, this code lets me make 1 house
I need a code that lets me make 3 houses next to each other
Can anyone help me by getting me on the right track or assisting me in a greater fashion
Thanks
Main:
import apcslib.*;
/**
* Write a description of class Main here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Main
{
public static void main(String[] args)
{
// create a Sketchpad that is 300 pixels by 300 pixels and
// a drawing tool
DrawingTool pen = new DrawingTool(new SketchPad(300,300));
// create the House object so that the lower left corner
// is at (-75,-75) within the SketchPad
int xStart = -75;
int yStart = -75;
int xStart1 = 25;
int yStart1 = -75;
int xStart2 = 125;
int yStart2 = -75;
House myHouse = new House(xStart, yStart);
House myHouse1 = new House(xStart1, yStart1);
House myHouse2 = new House(xStart2, yStart2);
// ask myHouse to draw itself using pen
myHouse.draw(pen);
myHouse1.draw(pen);
myHouse2.draw(pen);
/* myHouse.draw1(pen);
myHouse.draw2(pen); */
}
}
House Class:
import apcslib.*;
/**
* Write a description of class House here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class House
{
// instance variables - replace the example below with your own
private int myX;
private int myY;
private int myx1;
private int myy1;
private int myx2;
private int myy2;
/**
* Constructor for objects of class House
*/
public House(int x, int y)
{
// initialise instance variables
myX = -75;
myY = -75;
}
public void draw(DrawingTool aPen)
{
// instructions for drawing a house
aPen.up ();
aPen.move (myX, myY);
aPen.down ();
aPen.move (myX,myY+50);
aPen.move (myX+100,myY+50);
aPen.move (myX+100,myY);
aPen.move (myX,myY);
aPen.up ();
aPen.move (myX,myY+50);
aPen.down ();
aPen.move (myX+50, myY+75);
aPen.move (myX+100, myY+50);
aPen.up ();
aPen.move (myX+20,myY+20);
aPen.down ();
aPen.drawRect (20,20);
aPen.up ();
aPen.move (myX+80, myY+20);
aPen.down ();
aPen.drawRect (20,20);
aPen.up ();
aPen.move (myX+40, myY);
aPen.down ();
aPen.move (myX+40, myY+30);
aPen.move (myX+60, myY+30);
aPen.move (myX+60, myY);
}
}
