How to delete a word from the csv file when it is used so as not to have the same question twice with the same word and stop when all the words have been used?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
How to delete a word from the csv file when it is used so as not to have the same question twice with the same word and stop when all the words have been used?
Unless you want to parse the csv file yourself, you would need to use a utility class like in the Apache project to read in the lines of the csv file, delete the word and write out the updated csv file.How to delete a word from the csv file
If you don't understand my answer, don't ignore it, ask a question.
How can I do it I'm a beginner I don't know how to do it?
It may be a little complicated for a beginner.
Which way do you want to do it?
Write your own code to parse a csv
Use the packages from the Apache project
If you don't understand my answer, don't ignore it, ask a question.
import extensions.CSVFile;
CSVFile wordPrice = loadCSV("wordPrice");
class Word { String word; int price; }
void play (Word info) { int RightPrice = info.price; int Price; println("What is the price of'" + info.word); do{ counter = counter + 1; Price = readInt(); if (Price<RightPrice){ println("It's +"); } else if (Price>RightPrice) { println("It's -"); } } while(Price!=RightPrice);
Word randWord(){ Word mp = new Word(); int line = (int)(random() * rowCount(wordPrice)); mp.word = getCell(wordPrice, line, 0); String price = getCell(wordPrice, line, 1); mp.price = stringToInt(price); return mp; }
boolean replay(boolean exit) { println("Do you wan to play again (Y : Yes, N : No) ?"); char answer = readChar(); if(answer == 'N') { exit = true; } if(answer == 'Y') { exit = false; } return exit; }
boolean exxite = false; while(exxite == false) { Word randWord = randWord(); play(randWord); exxite = replay(exxite); }
csv name: wordPrice
There are two columns, one with the words and the other with the prices
Last edited by Alex123456; January 8th, 2022 at 03:47 PM.
Did you have any questions or comments about the code that you posted?
If you don't understand my answer, don't ignore it, ask a question.
I want to remove a word from the csv file when it is used so that I don't have the same question twice with the same word and stop when all the words have been used but I don't know how to do it
Can you write a detailed list of the steps that the program needs to take to solve the problem?I don't know how to do it
Do not try to write an java code yet.
When we have agreed on the steps the program needs to take, then pick the first step, write the code for it and test it.
When the test works, move to the next step and do the same.
If you don't understand my answer, don't ignore it, ask a question.