Creating an Interface for a class: error

Hi there,
I'm new to Java as you'll see from the question.
I created a class "Bicycle" and then went on to create an interface for it "InterBicycle" only I get the following error:
bad class file: C:\Documents and Settings\Melanie\Bicycle\src\bicycle\InterBicycle.java
file does not contain class bicycle.InterBicycle
I checked in the bicycle folder and the "InterBicycle.java" file is there.
Does anyone know where I am going wrong?
Butterfly82

Hey, thank you for that petes.
Silly mistake on my part, I was just reading about Inheritance and then went on to reading about Interfaces.
Changing this I came up with another error for each of the methods implemented by Bicycle.java:
C:\... applyBreaks(int) in bicycle.Bicycle cannot implement applyBreaks(int) in bicycle.InterBicycle; attempting to assign weaker access privileges; was public
Here is the code I have (Taken from The java Tutorial):
package bicycle;
class Bicycle implements InterBicycle {
    int cadence = 0;
    int speed = 0;
    int gear = 1;
    void changeCadence(int newValue) {
        cadence = newValue;
    void changeGear(int newValue) {
        gear = newValue;
    void speedUp(int increment) {
        speed = speed + increment;
    void applyBreaks(int decrement) {
        speed = speed - decrement;
    void printStates() {
        System.out.println("Cadence: " +cadence+ " Speed: " +speed+ " Gear: " +gear);
package bicycle;
interface InterBicycle {
    // List of the methods that the Bicycle class holds/implements
    void changeCadence(int newValue);
    void changeGear(int newValue);
    void speedUp(int increment);
    void applyBreaks(int decrement);
}

Similar Messages

  • How to create an interface if the class has a nested class

    I have the following class
    public class SampleImport{
    public SampleResult import (InputSource xml) {
    SampleResult sampleResult = new SampleResult();
              //do something
              return sampleResult;
    public static class SampleResult {
              public final String sampleName;
              public SampleResult (String s) {
                   sampleName = s;
    I would like to create an interface for this class for teh following method signature 'SampleResult import(InputSource(xml))', how would I create it ?
    Any help is appreciated,
    TIA,

    public interface Nameable {
        String getName();
    public interface Importable {
        Nameable importSource (InputSource xml);
    public class SampleImport implements Importable {
        @Override public SampleResult importSource (InputSource xml) {
            SampleResult sampleResult = new SampleResult("foo");
            //do something
            return sampleResult;
        public static class SampleResult implements Nameable {
            public final String sampleName;
            public SampleResult (String s) {
                sampleName = s;
            @Override public String getName() {
                return sampleName;
    }edit: er, you do know import is a keyword?

  • Creating Model Interfaces for GUI Layer

    I'm trying to avoid directly using a class from my model layer in my GUI. But I need to use a method in my class lets say, "setPropertyFoo(object)". So is it worthwhile to create an interface for my class, have my class implement the interface, and then use the interface in my view layer just for this one method? And the broader more general question is, is there a point at which one should not create interfaces? Are interfaces, though a standard of proper OOP programming, ever a symptom of an underlying poor design structure if they are needed in some way? I would hope not but I'm still learning.
    // Model layer
    public class MyClass implements MyInterface
         private Object foo;
         // For simplicity
         public void setPropertyFoo(Object obj)     
              foo = obj;
    public interface MyInterface
         // Just this...Just this one method...
         public void setPropertyFoo(Object obj);
    // View layer...
    MyInterface face = Factory.createMyClass();
    public void valueChanged(ListSelectionEvent event)
         <.....>
         face.setPropertyFoo(list.getSelectedValue());

    Your response sounds sensible to me. Thanks.
    Part of any piece of software will be about behavior.
    Part will be about data. Face it, a lot of what
    software does is move data around. IMHO, at boundaries
    between layers or modules (e.g. the DTO/DAO/VO for
    moving data between a database and your program), or
    wherever conversion occurs (to/from XML for instance)
    you may need some getters and setters.I agree.
    I try to avoid get/set in my code, but if I find I'm
    writing a whole bunch of goop just to achieve that
    grail, I stop and think about whether concealing that
    particular object's state really needs to be
    sacrosanct. And when I do provide access to that data,
    it's not just blind get/set that sets or returns any
    and all fields directly.This is helpful. It makes me think that there may be alternative means of achieving the same end without directly calling "set" on a field. Interesting.
    Off the top of my head, if
    you're doing a lot of passing objects as parameters to
    methods that just call getters and setters and act on
    the results, as opposed to saying
    object.doSomethingThatModelsABusinessAction().This is helpful too. I think I see what you are saying here.
    Using my example in the first post, I could modify it and say...
    // View layer...
    MyInterface face = Factory.createMyClass();
    public void valueChanged(ListSelectionEvent event)
         face.selectionResponse(list.getSelectedValue());
    // Then the model class...
    Public class MyClass implements MyInterface
         private Object foo;
         // For simplicity
         private void setPropertyFoo(Object obj)     
              foo = obj;
         public void selectionResponse(Object obj)
              setPropertyFoo(obj);
              // At least this gives the object more control
              // over whether or not to set the property at the
              // selection...
    }But I also appreciate what you've shared about the danger of the extreme point of view. From just what I've tried, I've been able to determine that it is possible to twist up a simple application and create more design flaws by attempting to eliminate each and every set or get method. So It's reassuring that I can leave some in where it makes sense to do so.

  • Not able to created Number Ranges for Asset Classes in AS08

    Dear Friends,
    I am not able create Number Ranges for Asset Classes in AS08.
    It is giving me an error message as company code does not exist.
    When I Check Consistency under path SPRO -> Financial Accounting -> Asset Accounting -> Preparing for Production Startup -> Check Consistency -> Overview Report: Company Codes. I am getting the following
    RSOL  Reliance Sealink One PLtd                                            
    CoCode no. alloc.    NKTR                                                
    Fiscal Year Variant  V3   Apr.- March, 4 special periods                 
    Start 2nd half month 00                                                  
    Transfer date        31.03.2006                                          
    Chart of dep.        TOLL Chart of Depreciation - For Highway Projects   
    Net worth tax        01   Book depreciation as per Compinies Act 1956    
    Enter net book value                                                     
    Status company code  2                                                   
    Current fiscal year  2007                                                
    Doc. type dep. pstng AF   Dep. postings                                  
    > Number range &1 in co.code &2 for doc.type &3 must be defined as internal
    Calc.insur.value                                                         
    Input tax exempt         
    If you see the above first two line you will find the difference is that Company code RSOL in the first line and NKTR company code in the second line.
    Actually CoCode no. alloc. has been wrongly copied as NKTR while copying CoCode it should be RSOL and not NKTR.
    I think because of this wrong allocation it is giving me an error in AS08. Also it is not showing me CoCode in drop down list in AS08.
    Please help me to resolve the problem.
    Thanks
    Rahul Jain

    Look in TC OAOB if the company code is assigned to a chart of depreciation

  • Creat transaction (se93) for Globa class in ABAP Objects

    Hi experts,
           Can any one tell me how to
    creat transaction (se93) for Globa class(se24)  in ABAP Objects
    if ,please assest me how to do it or send me example docu on this
    best Answer will be rewarded
    regards
    fareedas

    hi
    se93->give your transaction ->enter create.
    check the radio button (Method of calss(OO class).press enter.
    in next screen.
    transaction text ;give your own description
    tick the check box OO transaction model.
    give the class name method name which u have created in se 24.which was activated successfully.it should be activated otherwise it will not work.
    under GUI SUPPORT.
    TICK the all 3 check boxes.
    SAP GUI  FOR HTML
                            JAVA
                           WINDOWS.
    then save.
    u should b saved in package(don't forget).
    it was working.
    i have already checked and did it succesfully.
    reward points
    if u have any queries let me know.
    kiran jagana

  • Do we need to create message interfaces for idocs and rfcs thatare imported

    do we need to create message interfaces for idocs and rfcs thatare imported
    from sap server
    in scenarios from sap system to file or vice versa
    i knew that we need not create message types
    do we also skip creating message interfaces

    hi,
    you create an abstract message interface for IDOC only if you want to use
    them in a BPM (integration process)
    for more about IDOCs have a look at my book:
    <a href="/people/michal.krawczyk2/blog/2006/10/11/xi-new-book-mastering-idoc-business-scenarios-with-sap-xi"><b>Mastering IDoc Business Scenarios with SAP XI</b></a>
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • TestStand create different object for singleton class

    Hi all,
    we have a singleton class which has some functions used to do testing a harware.
    Our main Exe will create an object for that singleton class(which opens Com1 port and communicate with hardware). so the Exe will do basic communication test with hardware it is working well. We are using Teststand operator interface to do various testing by using sequence files. Main exe will use teststand usercontrols to execute tests when the user clicks Testbutton. after that, teststand try to create an object for that singleton but it returns new object not the existing one which is created by EXE. So it throwing me exeception "Com1 port access denied." (since we created object for signleton class @ very first in EXE)
    My question is Since that teststand runs in a separate Appdoamin will the singltonclass create separate object for different appdomain? if so is there any solution to reslove this?
    Hope i clearly explained my probs.
    Thanks in advance
    Srini 

    Hi Srini,
    How are you calling the executable?  From a Call Executable step?  Or are you using another means of calling it?   Also, why is TestStand trying to recreate the object?  As long as you have the correct handle to the object I don't think it matters what app domain you are in.
    Regards,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • Need help creating Vector table for specific class

    I am trying to create a Vector table of class Node and I think I understand the concept but in practice I am not
    sure why the compiler complains about non-static reference on statement mv.table.add(new Node(names[n]). Please help. I can not get this thing to work.
    import java.util.*;
    class MyVector {
    Vtable table;
    public static void main(String[] args){
    MyVector mv = new MyVector();
    String names[] = {"one","two","three","four","five"};
    for (int n;n<names.length;n++)
    mv.table.add(new Node(names[n])); //<-ERROR
    table.list();
    if (table.del("de")) System.out.println("deleted");
    table.list();
    public MyVector(){
    System.out.println("MyVector_C");
    table = new Vtable();
    public class Node {
    private String name;
    public Node(){name=new String("Null");}
    public Node(String s){name=s;}
    public void setName(String s){name=s;}
    public String getName(){return name;}
    public String toString(){return "[Node:"+name+"]";}
    public class Vtable extends Vector {
    private Vector v;
    public Vtable(){v=new Vector();}
    public void add(Node n){v.add(n);}
    public Node getNode(String s){
    Iterator i=v.iterator();
    while(i.hasNext()){
    Node n;
    n = (Node)i.next();
    if (s.equals((String)n.name))
    return(n);
    return null;
    public void list(){
    Iterator i=v.iterator();
    while (i.hasNext()){System.out.println((Node)i.next());}
    public Boolean del(String s) {
    Iterator i=v.iterator();
    while(i.hasNext()){
    Node n = (Node)i.next();
    if (s.equals((String)n.name)) {
    v.remove(n);
    return(true);
    return(false);
    }

    public class Vtable extends Vector {
    private Vector v;
    public Vtable(){v=new Vector();}
    public void add(Node n){v.add(n);}
    public Node getNode(String s){
    Iterator i=v.iterator();
    while(i.hasNext()){
    Node n;
    n = (Node)i.next();
    if (s.equals((String)n.name))
    return(n);
    return null;
    I get ur problem...
    When VTable extends Vector all u have to do is...
    VTable table=new VTable();
    table.add(new node(..));
    There is no need to get the Vector obj in picture as VTable extends Vector...
    I guess, this helps u.

  • Automation interface for specified class cannot be obtained

    I am trying to use a TestStand UI Expression Edit Control in LabVIEW to undertake an Expression.Evaluation, but I feel I must be missing something. I have a TestStand UI ExpressionEdit Control on the LabVIEW front panel, and when i try to evaluate it, or anything else (properties or methods) for that matter, the error is always the same:
    "Automation Interface for the specified class cannot be obtained. Check if the automation refnum type is the correct class for this operation" Error Code 3008; User defined error code.
    Any help tips or pointers would be appreciated.

    Hi
    To help resolve this issue can you post the VI which gives you this error.
    Regards
    Anand Jain
    National Instruments.

  • ALE interface for Sposnored Class in grants management

    Hi All,
    Is there any standard interface (ALE/IDOC/PROXY) provided by SAP for sponsored class in Grants Management module.
    Thanks,
    Swapnil Pawar

    Swapnil,
    Please see the Function Module GM_SPONSORED_CLASS_CREATE and determine if it works for you.
    Thanks
    Shyam

  • How to create WEBGUI interface for own-created program

    Hi experts!
    Could you please suggest me:
    Some of our end-users have to work with WEBGUI interface. In T-code VL02N we have our userexit SAPLZSDEXIT (Screen 0110). And in WEBGUI we don't see this tab in VL02N. I think I have to generate web-interface for this screen. But how I can make it? This screen was developed by our ABAP-ers in se51 t-code.

    Solved

  • How to create a constructor for this class?

    Hi everybody!
    I have an applet which loads images from a database.
    i want to draw the images in a textarea, so i wrote an inner class, which extends textarea and overrides the paint method.
    but everytime i try to disply the applet in the browser this happens:
    java.lang.NoClassDefFoundError: WohnungSuchenApplet$Malfl�che
         at java.lang.Class.getDeclaredConstructors0(Native Method)
         at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
         at java.lang.Class.getConstructor0(Class.java:1762)
         at java.lang.Class.newInstance0(Class.java:276)
         at java.lang.Class.newInstance(Class.java:259)
         at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)
         at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1778)
         at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)
         at sun.applet.AppletPanel.run(AppletPanel.java:293)
         at java.lang.Thread.run(Thread.java:536)
    so my class has no own constructor, it just has the paint method overwritten.
    my class looks like this:
    public class Malfl�che extends javax.swing.JTextArea{
    public void paint(Graphics g){
    Color grey=new Color(220,220,220);
    g.drawImage(img,10,10,null);
    how should a constructor for this class look like?
    sorry i am quite new to this, so i really dont have a clue!
    my class does not have any attributes or requires any so it doesnt need a constructor, doesnt it?
    thanks a lot
    tim

    If you have no constructor you cant instanciate (I know i just murdered that spelling) the object.
    Malfl�che thisHereThingie = new Malfl�che()assuming that you want to run that class by itself you will need a main method that has the preceeding code in it. If you are running it from another class you need to instanciate it... but anyway at the very least for a constructor you need.
    public Malfl�che(){

  • How to create Support function for internal Class use

    I have created a class to find the MoonRise and Set time. There is a java code available and I am translating it to Obj-C.
    My problem is that for the calculation there are many support functions which is internally used. When I try to duplicate this as follows
    -(double) frac:(double)x {
    // returns the fractional part of x as used in minimoon and minisun
    double a;
    a = x - floor(x);
    if (a < 0) a += 1;
    return a;
    -(void)minimoon:(double)t {
    // takes t and returns the geocentric ra and dec in an array mooneq
    // claimed good to 5' (angle) in ra and 1' in dec
    // tallies with another approximate method and with ICE for a couple of dates
    double L0, L, LS, F, D, H, S, N, DL, CB, L_moon, B_moon, V, W, X, Y, Z, RHO;
    //var mooneq = new Array;
    L0 = frac(0.606433 + 1336.855225 * t); // mean longitude of moon
    At this point it gives an error implicit declaration of function frac,
    My question is how to create such helper functions which are used internally, actually there are many such functions where functionA call B which calls C.
    Thanks
    Raj

    Here's yet another approach (creating a private category):
    @interface MYClass (Private)
    - (double)frac:(double)x;
    @end
    @implementation MYClass
    - (void)minimoon:(double)t {
    // takes t and returns the geocentric ra and dec in an array mooneq
    // claimed good to 5' (angle) in ra and 1' in dec
    // tallies with another approximate method and with ICE for a couple of dates
    double L0, L, LS, F, D, H, S, N, DL, CB, L_moon, B_moon, V, W, X, Y, Z, RHO;
    //var mooneq = new Array;
    L0 = [self frac:(0.606433 + 1336.855225 * t)]; // mean longitude of moon
    - (double)frac:(double)x
    // returns the fractional part of x as used in minimoon and minisun
    double a;
    a = x - floor(x);
    if (a < 0) a += 1;
    return a;
    @end
    <div class="jive-quote">rajkhand wrote:
    I liked the first method as I don't have to change much of the java code.
    I like it too. I use that very regularly (though I often use C++/Objective C++), since there is typically a lot of implementation in any class that does not need to be an ObjC instance method. This approach helps to reduce the object's interface to its essentials while keeping maintenance low.
    I'll put all the helper functions above the implementation.
    Is there a good book/web site where I can get such insight? I know C and Delphi/pascal
    Well, Objective-C is a superset of C. If you're porting Java, you'll find protocols (ObjC) similar to interfaces (Java).
    *Getting Started*
    Apple's version of ObjC is different from others. For the language, Apple's docs are the standard (IMO):
    Language:
    http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/ObjC.pdf
    If you are comfortable with C, this guide will help learning Objective-C quickly, though it has not been updated for (Apple's) Objective-C 2.0:
    http://www.amazon.com/Objective-C-Pocket-Reference-Andrew-Duncan/dp/0596004230/r ef=sr14?ie=UTF8&s=books&qid=1245404236&sr=8-4
    There are a few books on the ObjC2 language, but I have not read them (I just read Apple's docs for this).
    OOP/Design:
    http://developer.apple.com/documentation/Cocoa/Conceptual/OOPObjC/OOPObjC.pdf
    Research
    Good site for archives of tips, tricks, and even some hacks:
    http://www.cocoadev.com/
    Apple's lists (Cocoa, Xcode, ObjC, and specific technologies):
    http://lists.apple.com/mailman/listinfo
    This one sees the most traffic for Cocoa, and ObjC topics :
    http://lists.apple.com/mailman/listinfo/cocoa-dev
    Online archive for aforementioned Xcode and Cocoa list submissions:
    http://www.cocoabuilder.com/
    There are a lot of good sites/blogs out there as well.
    Questions
    Apple's lists (linked above) will typically yield good answers in a short time, you can also try here.
    Thanks a million
    Raj
    You're Welcome,
    J

  • Api or open interface for ABC class

    Hi All,
    Is ther any api or open interface available for mass updating items with new ABC class ?
    Regards,
    Sam

    There is no api. So recently, I had to use the following unsupported way to achieve this.
    There are no other relationships for this table so you can do a straight insert.
    insert into MTL_ABC_ASSIGNMENTS
    (select v.inventory_item_id, g.assignment_group_id,c.abc_class_id,sysdate,11531,sysdate,11531,null,null,null,null
    from MTL_ABC_ASSIGNMENTS_V v,MTL_ABC_ASSIGNMENT_GROUPS g, MTL_ABC_ASSGN_GROUP_CLASSES_V c
    where v.ASSIGNMENT_GROUP_NAME = 'OLD GROUP'
    and g.assignment_group_name='NEW GROUP'
    and c.abc_class_name= substr(v.abc_class_name,1,1) -- the new group is the first character of the old group
    and g.assignment_group_id = c.assignment_group_id
    --and inventory_item_id!=18895
    Hope this helps,
    Sandeep Gandhi

  • Creating GUI interface for cof

    I am attempting to create a GUI interface on Labview that will read the measurements from a load cell ( Futek model L2331) that is connected
    through a DAQ interface and  will output Coefficient of friction measurements vs time.  I would also like to be able to save the data to a file (eg...excel). 
    Can anyone help me out with this?
    JC

    What I suspect you need, more for comparison than anything else, is the Force in Newtons not the strain in µ strain.
    So one technique is to leave the input in volts and then figure out how many grams of weight gives how many volts from the load cell, and applying the necessory factors to give the force in Newtons unless of course your working in Christian units (lbs force).
    Either way, strain or volts you are going to have to calibrate the input. Unless the factors are all ready supplied. to arrive at the following
    "The
    coefficient of friction is simply µ =  Fspring /Fnormal
    =  Fspring /(mblock ·g
    ), g=9.81 m/s²"  Notice that there is no mention of strain here but force.
    Strain is defined as: - "The relative deformation of an object subjected to stress. Hence, strain is dimensionless."
    Don't forget to get the sense of compression and tension correct for the displayed units.

Maybe you are looking for

  • Previous itunes with a new ipod

    I am getting a new Ipod 30GB. My previous Ipod Mini is dead. Will I have a problem with itunes when I connect the new ipod to the computer?

  • Running Total in forms 4.5

    Hi, I have a forms 4.5 with a master and detail block. The detail block displays 15 record at a time. There is a column in the detail field whose total is to be displayed at the bottom. I am using post-query to sum this item and display it at the bot

  • Getting error:  *cannot check out a record*  in URM

    We have recently implemented URM and it seems to be working fine as far as checking in records and the dispositions working. The problem occurs if someone tries to check out a record. An error comes up saying that a record cannot be checked out. Am I

  • Call system functions from qnx or adobe flex (playbook tablet)

    Hi, I want to know how to access low level functions from the adobe flex sdk. For example, how i can get disk storage or cpu information when i use only the adobe flex sdk? Thanks,

  • How do I develop a character based form in Dev. 2000.

    I have a requirement of deveoping a form in character mode in Dev. 2000. Can any one guide me.