Salve ragazzi, il proff oggi ha spiegato questo piccolo esempio:
Codice PHP:
public class Student {
public String name = "";
public String gtNumber = "";
public int transcriptCount = 0;
public void identifySelf( ) {
System.out.println("My name is " + name);
} // identifySelf
public void requestTranscript( ) {
sendTranscript( );
transcriptCount++;
} // requestTranscript
public void sendTranscript( ) {
System.out.println("Sending transcript");
} // sendTranscript
} // Student
il mio problema è il segunete:Codice PHP:
public class GradStudent extends Student {
int cost;
public GradStudent() {
this.cost = 2; // oppure this.setCost(2);
} // constructor
public int getCost(){ return cost; }
public void setCost(int cost) { this.cost = cost; }
public void sendTranscript( ) {
this.identifySelf();
System.out.println("I am a graduate student.");
System.out.println("Transcript Cost: " + getCost());
setCost(getCost()+1);
} // sendTranscript
} // GradStudent
dove dice:
this.identifySelf(); non dovrebbe essere super???

Rispondi quotando
