Help coderanch get a
new server
by contributing to the fundraiser

tony narloch

Ranch Hand
+ Follow
since Dec 07, 2017
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
5
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by tony narloch

Hi guys;

I am trying to make a multi choice question based quiz and one of the question types needs to be a "fill in the blank". I am not sure how to do this.

I thought perhaps declare a data structure, such as an arraylist, which would store all the correct values such as follows:


ArrayList<String> questionContent=new ArrayList<String>();


Which I thought would output: "the capital of spain is"

I appreciate and recognise there is a lot of code duplication there, not 100% sure how to use a loop here. Something along the lines of:



And also use the .contains method to determine if the users choice was correct?

Again, not 100% sure how to implement this.



   
5 years ago

Does that mean you have been told to implement that interface? So names of cities are their natural ordering?



That is correct.
5 years ago


Got it working, hopefully this will serve as some help for others.
5 years ago
Class diagram Ritchie....
5 years ago

           
The error that is generated:
City is not abstract and does not override abstract method CompareTo(City) in Comparable.

Not sure whats wrong?

5 years ago
have stress tested the program, inserting multiple output.print(repository.toString());statements within it. For example, inserting 20 of the output.print(repository.toString()); statements wwill insert into the file generated, 20 "items:[]" which would lead me to think that there is an error within the Repository class/interface, but I am for the life of me utterly unsure as to how/why this is being generated.

I am not sure if the fact that files do not seem to be properly read is associated with this issue at present, or if rather, one error is merely masking another.
5 years ago



Latest form of my code.

Outputs:


Items: []
Items: []

How can I narrow down the possibilities of what is causing this please
5 years ago
So, here is the project in full.


City

https://pastebin.com/unNWPQFf

YearData

https://pastebin.com/hZ4TrHhJ

RepositoryInterface

https://pastebin.com/UNjdV6zq

DAOInterface

https://pastebin.com/KMn2njdd

FileReader
https://pastebin.com/iCaXFpa2

(There are other files but they are backend/haven't touched them)
5 years ago
Whenever I load a file or not, I get [] and Items:[] outputted.
5 years ago
Ok.



https://imgur.com/a/sPJ4mYj

The above code is the fileReader for the enclosed class diagram.

The one thing I have observed for the above code, we create several different objects, add the contents of the text file into them, and then add each of the objects to the repository at the end, which is then outputted.

Realising that there is striking similarity between the two, I have attempted to replicate it.

My code is as follows:



5 years ago
I dont understand this assignment at all, Ive spent 3 solid days on it. I'm just cutting my losses. Thanks anyway.
5 years ago
Ok, I understand, sorry I posted here guys and sorry for clogging the forum up. I can take a hint.

5 years ago
When I did some debugging at the Repository




Which would to me indicate that the add() method and the toString() method worked as expected? Hopefully this is one less thing we can cross off the list
5 years ago
The toString method in the model City file is as follows:

5 years ago