Re: using super



In article <srfcf.449727$tl2.350382@pd7tw3no>, fb took the hamburger,
threw it on the grill, and I said "Oh wow"...

> Hello Everyone. I am trying to declare a constructor that accepts the
> same parameters as the Transaction constructor and pass them to the
> Transaction constructor.
>
> I think this should work, but I'm rather new to 'super' (and OOP in general)
>
> So, (in regards to the following code):
>
> If I'm right, when I use the 'super' keyword, I'm actually calling the
> constructor of the Transaction class and passing in the variables.
>
> If I'm wrong...well, I'm sure you'll let me know. :-)
>
> abstract public class Transaction{
> //Data attributes
> ...
> ...
> ...
>
> //Constructor(s)
> Transaction(double amount, Date transDate){
> setAmount(amount);
> this.transDate = transDate;
> }
> }
>
> import java.util.Date;
> public class Credit extends Transaction{
> //Data attributes
> private double amount;
> private Date transDate;
>
> //Constructor(s)
> Credit(double amount, Date transDate){
>
> super(amount ,transDate);
> }
> }
>
> So...do you think I got it?
>

Yep. Just like that.

Now if you do anything else in the constructor, make super the first
line. You have to call super first before you do anything else.

--
Noodles Jefferson
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

"Our earth is degenerate in these latter days, bribery and corruption
are common, children no longer obey their parents and the end of the
world is evidently approaching."
--Assyrian clay tablet 2800 B.C.
.



Relevant Pages

  • Re: using super
    ... > constructor and pass them to the Transaction constructor. ... Somewhere here you must have defined 'Date transDate', ... Logically I would guess that you also have a 'double amount' in there ...
    (comp.lang.java.help)
  • Re: overloaded constructors
    ... I have 1 constructor that does not take any parameters and now i want to ... // get the connection string from the application settings ... public ADODatabaseWrapper(SqlTransaction transaction) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: using super
    ... same parameters as the Transaction constructor and pass them to the Transaction constructor. ... If I'm right, when I use the 'super' keyword, I'm actually calling the constructor of the Transaction class and passing in the variables. ... Date transDate){setAmount; this.transDate = transDate;}} ...
    (comp.lang.java.help)
  • SqlDataAdapter and optional transactions
    ... I recently switched from using MySQL to SQL server. ... connection the SqlDataAdapter will default to that pending transaction ... SqlDataAdapter constructor can't take a null transaction and assume ...
    (microsoft.public.sqlserver.programming)
  • overloaded constructors
    ... database wrapper that i created to encapsulate the ado functionality. ... have 1 constructor that does not take any parameters and now i want to ... // get the connection string from the application settings ... public ADODatabaseWrapper(SqlTransaction transaction) ...
    (microsoft.public.dotnet.languages.csharp)