Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java Abstract class and Interface issues in a code

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Java Abstract class and Interface issues in a code

    I have following code:

    package prototype;
    public interface Refill
    {
    public static final int TYPE_BALL=1;
    public static final int TYPE_GEL=2;
    public int getType();
    public int getPrice();
    }
     
    public abstract class Pen
    {
    public static final int TYPE_REFILLABLE=1;
    public abstract int getType();
    public abstract Refill getRefill();
    public   int getPrice();
    }
     
    public abstract class PushablePen extends Pen
    {
    public int state;
    public static final int STATE_NORMAL=1;
    public static final int STATE_PUSHED=2;
    public static final int TYPE_PUSHABLE=2;
    public static final int TYPE_ REFILLABLE _PUSHABLE=3;
    public abstract  void push();
    public abstract getState();
    }

    The classes are on different files with their names in 'Prototype'.
    I have another package 'Luxar' having following:

    package luxar;
    import prototype.Refill;
     
     
    public class BallRefill implements Refill 
    {
    	public int getType()
    	{
    	-------
    	}
     
    	public int getPrice()
    	{
    	---------
    	}
    }


    and there is a similar class GelRefill.In the same package sub class of Pen by the name P1 and a subclass of PushablePen, by the name P2.
    Now i am trying to test the above with a class in another package 'Tester' which tests:


    1)Price of Pen> Price of refill
    2)For pushable pen the states alternate between Pushed & Normal.
    3)Warning message if a Non-Pushable pen is pushed.
    Can anyone help me with these?

    Thanks,
    J


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,602
    Thanks
    45
    Thanked 1,956 Times in 1,930 Posts

    Default Re: Java Abstract class and Interface issues in a code

    Do you have any specific questions about your project? Please post them.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] Abstract method in a non-abstract class
    By bassie in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 2nd, 2012, 10:27 AM
  2. abstract VS interface
    By anis.laghaei in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 27th, 2012, 12:07 PM
  3. [SOLVED] Sahaja here. Need guidance. Interface and Abstract class
    By sahaja in forum Java Theory & Questions
    Replies: 2
    Last Post: July 4th, 2012, 04:43 PM
  4. What's difference between public class and abstract class?
    By Java95 in forum Java Theory & Questions
    Replies: 7
    Last Post: January 24th, 2012, 06:37 AM
  5. abstract class
    By robinglow in forum AWT / Java Swing
    Replies: 2
    Last Post: August 20th, 2010, 01:36 AM

Tags for this Thread