Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class (Day)

 
Eddy Ades
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I tried to wirte down my Day class, but I'm all confuse !!!

this is what I wrote , I'm getting all kinds of error when I'm compiling(beside the fact that the class is not complete !!)

If anybody can help me on this one, I'd really appreciate.
(once again, sorry if the code is in french, my java course is in french !!)




public class Journee {

// variable(s) de classe s'il y a lieu
private String lundi = "lu";
private String mardi = "ma";
private String mercredi = "me";
private String jeudi = "ju";
private String vendredi = "ve";
private String samedi = "sa";
private String dimanche = "di";

// variable(s) d'instance s'il y a lieu
String jourSemaine;

// constructeur(s) s'il y a lieu
public journee(String joursemaine){
lundi = new string(joursemaine);
mardi = new String (joursemaine);
mercredi = new String (joursemaine);
jeudi = new String (joursemaine);
vendredi = new String (joursemaine);
samedi = new String (joursemaine);
dimanche = new String (joursemaine);

}


// m�thode(s) de classe s'il y a lieu

// m�thode(s) d'instance s'il y a lieu
public String getSequence(){
return new String("lu");
}
public void setSequenece(Stringjoursemaine){
"lu"= new String(joursemaine);
}
public String getSequence(){
return new String("ma");
}
public void setSequenece(Stringjoursemaine){
"ma"= new String(joursemaine);
}
public String getSequence(){
return new String("me");
}
public void setSequenece(Stringjoursemaine){
"me"= new String(joursemaine);
}
public String getSequence(){
return new String("ju");
}
public void setSequenece(Stringjoursemaine){
"ju"= new String(joursemaine);
}
public String getSequence(){
return new String("ve");
}
public void setSequenece(Stringjoursemaine){
"ve"= new String(joursemaine);
}
public String getSequence(){
return new String("sa");
}
public void setSequenece(Stringjoursemaine){
"sa"= new String(joursemaine);
}
public String getSequence(){
return new String("di");
}
public void setSequenece(Stringjoursemaine){
"di"= new String(joursemaine);
}

public boolean equals(Sequence j1){
boolean result
if(this.lundi ==j1.lundi){
result = this.

} // Journee
 
Henry Wong
author
Marshal
Pie
Posts: 21218
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many errors, but here are some of the obvious ones...



1. Java supports overloading if the signatures are different. All your getSequence() and setSequence() methods have the same signatures.

2. I assume you don't mean "Stringjoursemaine", probably forgot the space.

3. You can't assign to a string literal. "di" is a value, not a variable.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic