Toon posts:

[java] overerving

Pagina: 1
Acties:
  • 51 views sinds 30-01-2008

Verwijderd

Topicstarter
Ik heb een probleempje met overerving. De foutmelding als volgt:

Java:
1
2
3
super.salaris = "" + aantal;  

syntax error: found 'super'.


De code staat hieronder:
Java:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
public class Werknemer
{    
     String id,salaris,soort,voornaam,tussen,achternaam,straat,
                   woonplaats,postcode,telnr,stuk,uur,werkSalaris;                
        
    public Werknemer(String id,String salaris,String soort,String voornaam,String tussen,String achternaam,String straat,String woonplaats,String postcode,String telnr)

    {  
        this.id = id;
        this.salaris = salaris;
        this.soort = soort;
        this.voornaam = voornaam;
        this.tussen = tussen;
        this.achternaam = achternaam;
        this.straat = straat;
        this.woonplaats = woonplaats;
        this.postcode = postcode;
        this.telnr = telnr;           
    }
    
    public String toString()
    {    
        return "*" + this.id +
         "*" + this.salaris +
         "*" + this.soort +
         "*" + this.voornaam +
         "*" + this.tussen +
         "*" + this.achternaam +
         "*" + this.straat +
         "*" + this.woonplaats +
         "*" + this.postcode +
         "*" + this.telnr ;    
    }      
}


public class Chef extends Werknemer
{  
   int aantal;
   
   public Chef(int aantal)
   {
       this.aantal = aantal;
   }
   
   public void berekenSalaris()
   {
       aantal = aantal *10
       super.salaris = "" + aantal;          
   }    
}


Weet er iemand waarom deze foutmelding wordt gegeven??

Verwijderd

Werknemer.salaris moet dan in ieder geval public of protected zijn.
Of private, en dan mooie set/get methodes maken.

  • Compubiter
  • Registratie: Oktober 2001
  • Laatst online: 21-08-2023

Compubiter

Think again

Dit hoort meer in Programming & Webscripting, maar ik denk niet dat je topic voldoet aan Welkom in P&W: FAQ en Beleid *updated: 27-06*
Lees dat dus eerst eens door, zodat je weet waar je topicstart aan moet voldoen :).

Dit topic is gesloten.