File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes using interface and how to implement them Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "using interface and how to implement them" Watch "using interface and how to implement them" New topic
Author

using interface and how to implement them

Duc Nguy
Greenhorn

Joined: Nov 12, 2001
Posts: 7
I have to develop number of vehicle types using the following interface. How do i use them
public interface Driveable
{
public static final int LEFT = 0;
public static final int RIGHT = 1;
public void start();
public void stop();
public void accelerate();
public void decelrate();
public void turn (int direction);
}
I have to write an classs for van, sedan that implement the inerface. please help.
James Hobson
Ranch Hand

Joined: Aug 28, 2001
Posts: 140
you want something like this
/**
* Put some javadoc here
*/
public class Van implements Driveable {
public static void main(String args) {
Driveable aVanInstance = new Van();
aVanInstance.start();
aVanInstance.turn(90);
aVanInstance.stop();
}

public void start() {
//do something
}
public void stop() {
//do something
}
public void accelerate(){
//do something
}
public void decelrate(){
//do something
}
public void turn (int direction){
//do something
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using interface and how to implement them
 
Similar Threads
Interface Concept in anonymous classes///
why not use interfaces for constants?
Requirement of Interface in Java
How to define constants for several classes?
(static ) variables in multple classes