Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How do I assign int values to values in a string array?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I assign int values to each value in a string array? I want to add a point for each question that is answered right. I want to make a questionnaire/quiz and ask the user a couple of questions about animals, and want to show them at the end the results on how many they got right at the end, so for example I want to them to see "you got 3/10 right" how do I do this? I also want to give them options to redo the quiz, look at the answers or quit, how do I also do this? I am using OOP so a class for my methods and a class from my calculations. here is my code so far and I would appreciate the help a lot. I have tried to look for solutions on my own but there is nothing specific for what I need, the things I have read and watched I don't know how to apply to my own work.




 
Saloon Keeper
Posts: 12133
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the first problem is that your class Quiz doesn't actually resemble a quiz.

If I go onto the street and ask people: "What does a quiz consist of?", I don't expect answers like "an array" or "an average" or "a sum". I expect answers like "questions" and "answers to questions".

One instance of a quiz might have multiple participants that give different answers to the same quiz. That means you might want to make a class AnswerSheet that keeps track of the answers that one participant gives to a particular quiz. You can then score each answer in the AnswerSheet.

Forget about the user interface for now. You first want to get your model right.
 
Jordan Belford
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using two classes for a reason, I can't forget about it. Also my logic was to find the average score of the people and then divide but that doesn't really make any sense now that I can think about it since I can just add a point. But how do I do this exactly? What code do I need?
 
Marshal
Posts: 69790
277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jordan Belford wrote:. . . What code do I need?

At the moment, none.

Until you have worked out what you are doing, you shouldn't have any code at all. As it is, you hve simply written confusing code which bears little resemblance to a quiz (as Stephan said). And why do you need two classes? That sort of decision at this stage looks wrong.
 
Master Rancher
Posts: 3857
35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is  the reason you don't want to do a design for the project because of  can't show my work because of security reasons?
 
Jordan Belford
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:Is the reason you don't want to do a design for the project because of  can't show my work because of security reasons?


Partially but I changed the class names and variables so they're different to my actual ones so the security issue is no longer there. I have most of the concepts in my head but I don't know how to implement them into my program and I tried to find a way of doing it but there's no solution to my specific problem and so this is why I made this thread
 
Norm Radder
Master Rancher
Posts: 3857
35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have most of the concepts in my head


Good, that is a first step.  Now for us to be able tp help you improve and implement your design can you post  the details of the design so we can work on that before trying to write any code.
Once there is a good design for the program. then you could ask specific questions about any of the steps that are giving you a problem.  
 
Jordan Belford
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:

I have most of the concepts in my head


Good, that is a first step.  Now for us to be able tp help you improve and implement your design can you post  the details of the design so we can work on that before trying to write any code.
Once there is a good design for the program. then you could ask specific questions about any of the steps that are giving you a problem.  



What do you mean by design?
 
Norm Radder
Master Rancher
Posts: 3857
35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By design I mean to make a detailed list of what the program is supposed to do and the steps it should take to do them.

In the link Campbell gave you: https://coderanch.com/wiki/659765 it talks about designing a kitchen.
 
Sheriff
Posts: 15759
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jordan Belford wrote:What do you mean by design?


Design is a bunch of things but essentially, it's how different parts come together. If you don't have a good idea of what the design is, you're going to have a really hard time putting things together. A blueprint is a design. If you have a bunch of machine parts, how those parts are assembled together to form a machine is the design.

In programming, designs consist of ideas, intentions, and programming language elements that come together to form software that does something useful.
 
    Bookmark Topic Watch Topic
  • New Topic