Pad.java
/*
* Copyright © 2012 Nokia Corporation. All rights reserved.
* Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
* Oracle and Java are trademarks or registered trademarks of Oracle and/or its
* affiliates. Other product and company names mentioned herein may be trademarks
* or trade names of their respective owners.
* See LICENSE.TXT for license information.
*/
package com.nokia.example.drumkit.components;
/**
* Drum pad
*/
public class Pad {
private int sound = 0;
private Rectangle boundingBox;
private boolean hit = false;
public Pad(int sound, int x, int y, int width, int height) {
this.sound = sound;
boundingBox = new Rectangle(x, y, width, height);
}
/**
* Mark the pad hit
* @param b
*/
public void setHit(boolean b) {
hit = b;
}
/**
* @return True if the pad has been explicitly marked hit
*/
public boolean isHit() {
return hit;
}
/**
* Get the sound assosiated to the pad
* @return One of the sounds defined in SoundManager
*/
public int getSound() {
return sound;
}
/**
* Assosiate sound to the pad
* @param sound One of the sounds defined in SoundManager
*/
public void setSound(int sound) {
this.sound = sound;
}
/**
* Get the bounding box of the pad
* @return
*/
public Rectangle getBoundingBox() {
return boundingBox;
}
/**
* Set the bounding box for the pad
* @param boundingBox
*/
public void setBoundingBox(Rectangle boundingBox) {
this.boundingBox = boundingBox;
}
/**
* Check whether a point is inside the bounding box
*/
public boolean contains(int x, int y) {
return boundingBox.contains(x, y);
}
}