• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help with a Java project  RSS feed

 
Yann Danis
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am a computer enthusiast and I'm learning to program in Java. Its the first computer language I learn. Despite my difficulties xD I'm progressing ... so I decided to start a project. Its a basic program that asks users questions with different kinds of answer styles some answers need to be descriptive some will be by choices A,B,C or D ...: D The program contains five classes that I developed (with some help and resourcefulness).
But I am still in a dead end and I would like someone to help me if possible... Thank you in advance and it is appreciated...
Here is the code with errors for one of the 5 classes.


Thanks for your time.
If you choose to help its really appreciated! I know I wont be abe to learn it all by myself. XD
 
Sagar Dabas
Ranch Hand
Posts: 47
C++ Java PHP
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Where have you instantiated autreObj .

2.

3.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yann. Welcome to The Ranch!

If you really want us to effectively help you, it would be helpful if you actually asked a question. What's the problem that you have at the moment?

 
Yann Danis
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:Hi Yann. Welcome to The Ranch!

If you really want us to effectively help you, it would be helpful if you actually asked a question. What's the problem that you have at the moment?


1.Whit the autreObj I'm trying to find a code to verify an answer...
and sorry my project is in french since I'm french Canadian... xD

2. rep is short for reponse which means answer in english...

3. public void affiche would be in english public void display
return texte return text
Here I'm trying to tell the program to display a question.
 
John Jai
Rancher
Posts: 1776
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fear Mathew rather asked you to tell the Errors you face while compiling / running the code.
 
Yann Danis
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:Hi Yann. Welcome to The Ranch!

If you really want us to effectively help you, it would be helpful if you actually asked a question. What's the problem that you have at the moment?


At the moment I have to much problems with my project... xD
So I'm trying to find help to sort at least one of them out because I'm getting pretty much discourage here. :,(
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yann Danis wrote:If you choose to help its really appreciated! I know I wont be abe to learn it all by myself. XD

Well, first of all you've only shown us 1 of your 5 classes; it would be nice to at least know the names of the others.

Second, you might want to look at Java Generics, because it will allow you to associate a Question (assuming that all Questions are the pretty much the same) with a particular type of answer (or indeed an Answer (see below) with an expected type of response, eg: Integer or String).

Thirdly, your Question class seems to be tied directly to the answer. There's nothing particularly wrong with this, but you might find it a bit more flexible if you separate the two. A Question might then have a number associated with it, indicating its position in an exam paper; and an Answer might include methods to allow examiners to grade the Answer.

Finally, I suspect you'd be better off using interfaces for your main types, and then hanging implementation classes from them. For example (and this is only an example; there are many possibilities):HIH

Winston
 
Yann Danis
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My errors are :

1.Multiple markers at this line
- autreObj cannot be resolved to a variable
2.rep cannot be resolved to a variable
3.Void methods cannot return a value
 
John Jai
Rancher
Posts: 1776
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yann Danis wrote:So I'm trying to find help to sort at least one of them out because I'm getting pretty much discourage here. :,(

Cool Sagar has already addressed the specific errors in the code. Just giving some text for them -

1. The autreObj in the verifieResponse method is not declared. It should be declared like the texte or response object.
But I think it will be a input parameter to the method just like the rep variable,
so the method signature will be like


2. You try to assign the value read by the Scanner to a variable named rep that is either not declared as a local variable in the getResponse() method or as an instance variable.
I think you intend to store the lecteur.nextLine() output to the response variable.

3. Methods declared void should not return any value. So change the affiche() method's return type from void to the type of the texte variable.

And next time be little more Patient
 
Yann Danis
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
Yann Danis wrote:If you choose to help its really appreciated! I know I wont be abe to learn it all by myself. XD

Well, first of all you've only shown us 1 of your 5 classes; it would be nice to at least know the names of the others.


Winston

ok I will put the class names in english...
AnswerChoicesQuestion
wich would help do like what is 2 + 2
a) 1
b) 2
c) 3
d) 4
I dont know if thats english... but Questionnaire xD
QuestionnaireTest
and finally NumericalQuestion
wich would be like what is 2 + 2?
4
 
Yann Danis
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Jai wrote:

And next time be little more Patient


Sorry if you felt I'm impatient but I didn't mean any harm there I meant discourage about finishing my project... xD

I've been on this for 3 weeks now. :'S

Actually I fell very grateful for the help!

But anyways thanks for your time!
 
John Jai
Rancher
Posts: 1776
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yann Danis wrote: because I'm getting pretty much discourage here. :,(

My bad - I mistakenly thought you were discouraged in the forum
Anyways cheers
 
Yann Danis
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help everyone I've finished my project and now I can start a new one that is gonna be a little bit harder.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!