Kristers Drozds

Greenhorn
+ Follow
since Oct 30, 2015
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kristers Drozds

I cant find the issue why it's not counting up, but showing some random numbers.

6 years ago
Hey, just wanted to ask is there any decent tutorials to export data from jLabel for example?

I got a jTextbox where user enter his name and surname...and i got jLabel that shows his result.

I want to export them to a excel as user pushes button finish, how can i do that?
6 years ago

Les Morgan wrote:Here is a very basic layout. You can put a button on the bottom and more on to the next question, and use the setText method in the JRadioButton and JLabel to change the text for the next QA round.



Hey thanks for fast response, but i want to make that questions+ answers is taken from constructor.


and i have no idea how to make it work.
Cause i want to make a random quiz, that takes 10 questions out of 100.
I had an idea to make a list of questions and shuffle the list... but i have no idea how to make answers follow the question.

Or its just better to use setText?
6 years ago
Hello, first of all i'm kinda new to gui.
I'm making a Quiz with Question - Answers.
How can i make my Questions to show in Jlabel and answers on JRadiobuttons?
and when somebody clicks next button it shows next questions + answers.


6 years ago

Carey Brown wrote:In OO you would create a Question class. Your main class would contain a List<Question>. The Question class would contain a List<String> for the answers and an int of which answer is correct You main class would shuffle the Question list ... Collections.shuffle( questionList ) ... (if I remember correctly).

You could add another layer of abstraction by having an Answer class. An Answer class would have a String for the question and a boolean to flag the correct answer. In this way you could also shuffle the answers.



Thanks didnt see this post earlier, gonna try it .
6 years ago

Liutauras Vilda wrote:Initially I was thinking about to suggest you to ease your life with HashMap instead of parallel arrays, but Campbell Ritchie is right, that would be a changing of one bad way doing this with another bad way.

So you most likely need to consider of moving to Objectville. Have you learned about writting classes yet?

I can't remember in which book I've seen such problem, I think it was in one of: either "Head First Java" or Cay Hortsmann "Java for Everyone, Late Objects". If I'm not mistaken, there are good suggestions and hints how to implement it in object oriented way.

If you're thinking to move along with this app further, you could try to look up for those books in your local library.



Yes, i kinda know a basic about Object Oriented Programming and how to write class.
I just didn't get the idea... so i should make new class + object for questions and new for answers as well? Or i need to mash them in 1 class?
Dont get it how to make an answers follow the question to be honest.


main:
6 years ago

Campbell Ritchie wrote:The answer is really simple: get some objects and beat them into submission. Create a Question class which encapsulates both question and answer. When you sort/search/randomise the questions, all the answers will follow.


Last question :


These are answers for each Question, and can i somehow split them on 4 different radio buttons?
Cause answers[0] will display :
(1) centralizētā vadība (2) sacensību princips (3) ar marķiera palīdzību (4) token passing
and can i split them so i can put each of them on different radio button?
6 years ago
Well i got program working on console, first semester i made it without gui. But on 2 semester i want to make it with gui and more complete.

I have 2 different arrays:
*questions array
*answers array
The Question is, how can i put answers to the correct question after array shuffle?

In my old program i used this(no shuffle array):


The first semester program, i can upload or send it to you as well.
6 years ago

Liutauras Vilda wrote:Welcome to the Ranch.

Difficult to determine if you chose right approach in general, for solving that problem.
Could you please specify how that test question sounds?

[edit] I am sorry, I misread your post. I thought you're solving test, it appears you're creating one.

Still, question remains similarly, do you have whole idea what your program is supposed to be doing? Could you please explain a bit more about it.


Hey, thanks for the fast response.

I'm creating a "Test".
There will be around 100 Questions in a Array. Each Question will hold 4 answers(4 radio buttons).
1. Question 1
Answer 1 Answer 2 Answer 3 Answer4
The Question array will be shuffled. And the first 0-9 index i will display them as questions after shuffle, so when you open the program again, it's not the same questions over, over again.

Don't know still if i'm gonna put all 10 questions in 1 Jframe or on button click.

I hope you did get my idea.
6 years ago
Hello,
So i got some issues about arraylist shuffle.
I'm making a "Programming test".
There is around 100 questions, so i wanted to make so it shuffles all array.
I did that, but how can i make it so answers array knows - what question is about to display after shuffle so i can display correct answers for that question?

6 years ago
Is it possible to put an array with questions and answers in the same gui file? Cause it's telling me that i need to make another file for that.
also i did make another file in the same package and import it into gui file but it still telling me that variable is unknown.

Les Morgan wrote:


Well what is better in your opinion to learn to write pure code or use gui builder?
Hello,
So question i got how to add the array into label, when i push the button next it takes next value from array and so on till 10 questions have been displayed.


when i add a label to design log it generates


How can i put so it takes first index from array and displays it into lable and when you push button next it takes next array value and displays it.
I'm kinda a new to eclipse gui thingy, i tried -
Greetings,
I need to check if atbilde contains any char(symbols) if it does, then -
System.out.println("You have entered symbol line");
System.out.println("Reverse" + teksts.reverse());

Could you help me with this please?

6 years ago

Jeanne Boyarsky wrote:The removeFirst() method returns the start value in addition to removing it. For example:



Note that it is Java convention to have classnames begin with a capital letter along with subsequent "words" rather than using underscores. Making your class name KristersDrozds3.



Thanks for reply, well that dont work for me cause i need to display 10 methods.
for example :


Object tre will take first list value


but i want to make it so it takes firsts value of list.


im bit confused.
6 years ago