Results 1 to 2 of 2
  1. #1
    Hector is offline Member
    Join Date
    Feb 2014
    Seattle, Washington
    Rep Power

    Default Driver for lockable coin class

    im having trouble creating a driver for the following program. im new to creating interfaces and i need to make this work. i jus need a push in the right direction, so any help is appreciated. thanks in advance

    Lockable interface:
    Java Code:
    public interface Lockable {
    	  boolean locked();
    	  public void setKey(int key);
    	  public void lock(int key);
    	  public void unlock(int key);
    Coin class:
    Java Code:
    public class Coin implements Lockable {
    	 private boolean locked;     
    	 private int key ;       
    	 public Coin(){         
    		 locked = false;        
    		 key = 0 ;     
    	 public boolean locked(){         
    		 return locked ;     
    	 public void setKey(int key){         
    		 this.key = key ;     
    	 public void unlock(int key){         
    		 if(this.key == key){            
    			 locked = false ;         
    	 public void lock(int key){         
    		 if(this.key == key){             
    			 locked = true ;         
    	 public void messageReturn(){        
    		 if(locked == false) 
    			System.out.println("unlocked") ;

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power

    Default Re: Driver for lockable coin class

    Start with a main() method that creates an instance of Coin and calls the functions on that instance. Do the functions do what you expect them to do?
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

Similar Threads

  1. Lockable interface and driver
    By Hector in forum Advanced Java
    Replies: 1
    Last Post: 02-18-2014, 06:08 PM
  2. Driver Class Program Help
    By smarty84handsome in forum New To Java
    Replies: 13
    Last Post: 12-08-2013, 10:04 AM
  3. Replies: 0
    Last Post: 03-03-2012, 01:01 AM
  4. Replies: 6
    Last Post: 02-08-2012, 06:42 PM
  5. using a driver with a class
    By vendetta in forum New To Java
    Replies: 7
    Last Post: 01-11-2010, 06:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts