SkAkKo
06-11-2006, 19.34.30
ciao a tutti!
Ho le seguenti classi:
Studente.java
package pack;
import java.util.*;
import java.awt.*;
import java.lang.*;
public class Studente implements Cloneable {
String nome;
int anno;
public Studente(String nome,int anno) {
this.nome = nome;
this.anno = anno;
}
public String toString(){
return "\nNome: "+ this.nome+"\nAnno: "+ this.anno+"\n";
}
public boolean equals(Object o) {
if (o.getClass() != this.getClass())
return false;
Studente s = (Studente) o;
if ((s.nome.equals(this.nome) && (s.anno == this.anno)))
return true;
return false;
}
public Object clone() {
try {
return super.clone();
}
catch (CloneNotSupportedException e) {
return null;
}
}
}
Corso.java
package pack;
import java.util.*;
import java.awt.*;
import java.lang.*;
public class Corso implements Cloneable {
String nome;
String docente;
LinkedList elenco;
public Corso(String nome,String docente) {
this.nome=nome;
this.docente=docente;
this.elenco = new LinkedList();
}
public Corso () {}
public void AggiungiStudente(Studente s){
this.elenco.add(0,s);
}
public void RimuoviStudente(int i){
this.elenco.remove(i);
}
public String toString(){
return "\nNome Corso: "+ this.nome + "\nNome docente: "+ this.docente+"\nElenco Studenti: "+elenco;
}
public boolean equals(Object o){
if(o.getClass() != this.getClass())
return false;
Corso c = (Corso) o;
if ( (!c.nome.equals(this.nome)) || (!c.docente.equals(this.docente)) )
return false;
for (int i=0;i<this.elenco.size();i++)
if (!this.elenco.contains(c.elenco.get(i)))
return false;
return true;
}
public Object clone() {
try {
Corso d = new Corso();
d = (Corso) super.clone();
d.elenco = new LinkedList();
Studente s;
for (int i=0;i<this.elenco.size();i++) {
s = (Studente) this.elenco.get(i);
d.elenco.add(s);
}
return d;
}
catch (CloneNotSupportedException e) {
return null;
}
}
}
la classe Studente la compilo..mentre Corso mi da il seguente errore:
Corso.java:20: error: Type ‘Studente’ not found in the declaration of the argument ‘s’ of method ‘AggiungiStudente’.
public void AggiungiStudente(Studente s){
^
1 error
levando package pack;
compila...
qualche idea ? grazie ;)
Ho le seguenti classi:
Studente.java
package pack;
import java.util.*;
import java.awt.*;
import java.lang.*;
public class Studente implements Cloneable {
String nome;
int anno;
public Studente(String nome,int anno) {
this.nome = nome;
this.anno = anno;
}
public String toString(){
return "\nNome: "+ this.nome+"\nAnno: "+ this.anno+"\n";
}
public boolean equals(Object o) {
if (o.getClass() != this.getClass())
return false;
Studente s = (Studente) o;
if ((s.nome.equals(this.nome) && (s.anno == this.anno)))
return true;
return false;
}
public Object clone() {
try {
return super.clone();
}
catch (CloneNotSupportedException e) {
return null;
}
}
}
Corso.java
package pack;
import java.util.*;
import java.awt.*;
import java.lang.*;
public class Corso implements Cloneable {
String nome;
String docente;
LinkedList elenco;
public Corso(String nome,String docente) {
this.nome=nome;
this.docente=docente;
this.elenco = new LinkedList();
}
public Corso () {}
public void AggiungiStudente(Studente s){
this.elenco.add(0,s);
}
public void RimuoviStudente(int i){
this.elenco.remove(i);
}
public String toString(){
return "\nNome Corso: "+ this.nome + "\nNome docente: "+ this.docente+"\nElenco Studenti: "+elenco;
}
public boolean equals(Object o){
if(o.getClass() != this.getClass())
return false;
Corso c = (Corso) o;
if ( (!c.nome.equals(this.nome)) || (!c.docente.equals(this.docente)) )
return false;
for (int i=0;i<this.elenco.size();i++)
if (!this.elenco.contains(c.elenco.get(i)))
return false;
return true;
}
public Object clone() {
try {
Corso d = new Corso();
d = (Corso) super.clone();
d.elenco = new LinkedList();
Studente s;
for (int i=0;i<this.elenco.size();i++) {
s = (Studente) this.elenco.get(i);
d.elenco.add(s);
}
return d;
}
catch (CloneNotSupportedException e) {
return null;
}
}
}
la classe Studente la compilo..mentre Corso mi da il seguente errore:
Corso.java:20: error: Type ‘Studente’ not found in the declaration of the argument ‘s’ of method ‘AggiungiStudente’.
public void AggiungiStudente(Studente s){
^
1 error
levando package pack;
compila...
qualche idea ? grazie ;)