Advertisement
fosterbl

Block

Feb 24th, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. class Block{
  2.    private int xPos;        //x position of the block
  3.    private int yPos;        //y position of the block
  4.    private int blockWidth;  //width of the block
  5.    private int blockHeight; //height of the block
  6.  
  7.    private color blockColor;    //color of the block
  8.  
  9.    public Block(){
  10.      …
  11.    }
  12.  
  13.    
  14.  
  15.  
  16.    //add other Block constructors
  17.  
  18.  
  19.  
  20.  
  21.    
  22.    //mutators, add others
  23.    public void setPos(int x, int y){}
  24.    public void setX(int x){}
  25.    public void setY(int y){}
  26.  
  27.  
  28.  
  29.    public void display(){
  30.       fill(blockColor);
  31.       rect(xPos, yPos, blockWidth, blockHeight);
  32.    }
  33.  
  34.    public void display(color col){
  35.       fill(col);
  36.       rect(xPos, yPos, blockWidth, blockHeight);
  37.    }
  38.  
  39.    public boolean equals(Object other){
  40.      …
  41.    }
  42.  
  43.    public String toString(){}//hint: the function red(blockColor) will give the amount of red in blockColor
  44.  
  45.    //accessors, add others
  46.    public int getX(){}
  47.    public int getY(){}
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement