Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #36175 > unrolled thread

Where am i going wrong

Started bySuperGiirl <kainattshafiq90@gmail.com>
First post2017-01-08 17:37 -0800
Last post2017-01-08 19:12 -0800
Articles 3 — 3 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Where am i going wrong SuperGiirl <kainattshafiq90@gmail.com> - 2017-01-08 17:37 -0800
    Re: Where am i going wrong Arne Vajhøj <arne@vajhoej.dk> - 2017-01-08 21:20 -0500
    Re: Where am i going wrong Davej <galt_57@hotmail.com> - 2017-01-08 19:12 -0800

#36175 — Where am i going wrong

FromSuperGiirl <kainattshafiq90@gmail.com>
Date2017-01-08 17:37 -0800
SubjectWhere am i going wrong
Message-ID<ebaa620e-2ecc-429c-9a6e-f71fd3e9c945@googlegroups.com>
public class Mobile extends Gadget
{
    // instance variabrles 
    private int creditRemaining;

    /**
     * Constructor for objects of class Mobile
     */
    
    public Mobile(int creditRemaining, int theWeight, double thePrice, String theModel, String theSize);
    {
           super(theWeight, thePrice, theModel,theSize);        
           creditRemaining = RemainingCredit; 
    } 

this is the coding for the subclass, the superclass of gadget
can someone please tell me where I am going wrong, as I am new to this.

thank you :)

[toc] | [next] | [standalone]


#36176

FromArne Vajhøj <arne@vajhoej.dk>
Date2017-01-08 21:20 -0500
Message-ID<o4us1b$1ed0$1@gioia.aioe.org>
In reply to#36175
On 1/8/2017 8:37 PM, SuperGiirl wrote:
> public class Mobile extends Gadget
> {
>     // instance variabrles
>     private int creditRemaining;
>
>     /**
>      * Constructor for objects of class Mobile
>      */
>
>     public Mobile(int creditRemaining, int theWeight, double thePrice, String theModel, String theSize);
>     {
>            super(theWeight, thePrice, theModel,theSize);
>            creditRemaining = RemainingCredit;
>     }
>
> this is the coding for the subclass, the superclass of gadget
> can someone please tell me where I am going wrong, as I am new to this.

It is a bit hard to tell with a description of what the problem is.

But a guess:

creditRemaining = RemainingCredit;

->

this.creditRemaining = creditRemaining;

Arne


[toc] | [prev] | [next] | [standalone]


#36177

FromDavej <galt_57@hotmail.com>
Date2017-01-08 19:12 -0800
Message-ID<31880009-63f0-48cf-9062-ec4e2aa90565@googlegroups.com>
In reply to#36175
On Sunday, January 8, 2017 at 7:37:15 PM UTC-6, SuperGiirl wrote:
> [...]

Obviously you have a problem with your variable naming. Do you 
understand what you are doing? You can name a passed parameter 
and the instance variable the same if you use the prefix "this" 
to distinguish between them, as Arne demonstrates. You might 
want to review the online tutorial...

http://docs.oracle.com/javase/tutorial/java/javaOO/thiskey.html 
http://docs.oracle.com/javase/tutorial/java/javaOO/classes.html 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web