Why User id not enter in sequence? [closed] - java

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
The problem is, User id enter randomly, or not enter in sequence like this:
problem description
The last entry is "bill" why is "Warren" shifted to number three? This shift makes my bar chart not sequential on the x Axis.
What I want is "Warren" to stay in second place and "bill" must be under the "Warren".
this is my code:
...
DatabaseReference reference = db.getReference("Attendance")
reference.child(uid).setValue(new CurrentAttandance(cA, userCount, xname));
any help thank you guys. :-)

The "random" user ID you're stating is not appearing automatically or it is not just any random bunch of String characters. It looks like the uid of the user.
Please add the code, but from the output I am guessing that you're adding your users in the database, with code that looks something like this:
ref.child(mAuth.getUid()).child("xname").setValue(name);
This is the reason that the Strings are appearing as the parent child in your Firebase database.
Also as #J.A.P correctly pointed in the comment, the order is according to the lexicographic nature of the parent Strings that are uid of the user in your database.
If you want them to be ordered according to order by which they sign up, then add a timestamp in your Firebase Database as sibling child of xname and show the list in order of your timestamp.

Related

Can't use the method of the items in the Default Linkedlist in Java [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 19 hours ago.
Improve this question
I was trying to use the default linked list provided in java, however, it seems like I can't use the method I created for the item in the using the linked list. This is very weird, it seems like I can only access the method if I have a concrete object, not when trying to implement method from a object that haven't been created yet.
this image below shows where I get the problem
enter image description here
However, I did implement a method in the Card class
enter image description here
This is very weird, cuz the method work on the individual object I created
enter image description here
Can't figure out why, is the default linked list in java just stupid?
I just can't get it working somehow

Firebase realtime data base android java [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
Can someone answer my question: Why i can't create child in root like this:
mDatabase.child("teams").child(uniqueIDstr).child("members").child(currentUser.getEmail()).setValue("XD");
because something like this is working properly:
mDatabase.child("users").child(currentUser.getUid()).child("groups").child(uniqueIDstr).setValue("group");
The problem is in this call child(currentUser.getEmail()). An email address always contains at least one . and that character is not allowed in keys in the Firebase Realtime Database. You should actually be getting an error message when you run that code that pretty explicitly tells you this.
The common solution is to "encode" the email address, for example by remove the .s from it or by changing each . to a ,. The latter is a neat trick, since , is not allowed in email addresses while it is allowed in Realtime Database keys.

How to validate and save JtextField information to a csv file? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I wanted to know how I can validate data in a jtextfield (or if any data is actually entered) then save the validated data to a file in csv format.
Each (more or less) textField has a different data type for example; string, int, double, etc. and I want to see if they meet certain requirements such as length, if they are letters, numbers, contain certain letters or numbers only.
Hope you can help.
Code is in google drive, Click here!
Note: It's an eclipse project.
Each (more or less) textField has a different data type for example; string, int, double, etc
You can use different components to help with this. For example you might use a JSpinner for numeric values. Check out the section from the Swing tutorial on How to Use Spinners for more information and examples.
if they meet certain requirements such as length
For lengths of text you can use a DocumentFilter to limit the text. Check out the section from the Swing tutorial on Implementing a DocumentFilter that does exactly this.
contain certain letters or numbers only.
Maybe you can use a JFormattedTextField. Read the section from the Swing tutorial on How to Use a Formatted Text Field.
I hope you get the idea. Start with the tutorial. Look at the table of contents to see what features are available.

Java recursively exercise [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm in need of some guidance on the following exercise.
I have a custom list in which it has cities, each city knows to which city it connects this is the route, the route has a time which it take you to get between cities. What im asked to do is: given a city and sometime X:
public IList citiesWithRange(City c, int timeMinutes);
I should return to all the cities I can reach within that time frame. IList is a list made by me. Any help would be appreciated.
Thanks.
What you need is an implementation of an algorithm which returns the paths between nodes in a graph.
Take a look at Dijkstra's algorithm here:
https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
This can be helpful too:
https://www.ics.uci.edu/~eppstein/161/960208.html
You can attempt to solve this problem with a few easier steps in your recursive function
This function should be called on the starting city and be given a stack to add valid cities too, as well as an amount of time
Exit if time remaining is negative
Log current city to a stack
Loop through all connecting cities, calling the recursive function on each of them with the stack and time remaining minus travel time
At the end of this, the stack will contain all valid cities and may have duplicates
Remove the duplicates and you have all of the possible cities you can travel to

Creating a dialogue in Java with libGDX [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to make a dialogue tree (conversation tree) in Java using libGDX. Should I use lots of conditionals (if,else etc...) and move on to the next dialogue or is there a better way to read a file such as XML that already have the dialogues inside? Also, I want the solution that would consume the least possible memory amount because I am going to write it for Android.
Example of the dialogue tree:
(Q: Question, A: Answer , C:Choice ,AC:Action)
Q:Hi is there anyway that i can help you?
A:You own me 5 dollars!
C1:Ask politely to return them to you, C2:Τhreaten her , C3:Draw your gun
A1:No way get out of here , A2:Call the security , A3:Call the cops
AC1-2:Exit the building //end of choices 1-2
C3.1:Draw your gun and shoot the cops , C3.2:Jump from the window
AC3.1:Arrested , AC3.2:Dead
If your game is going to have little dialogue, I would use Strings for it, but if you base it around the dialogues, I would use a SQLite or similar database to store them in it. I don't know whether it will be the most efficient way to do that, but that what's occurred to me while reading your question:
You could use e.g. column 1 for the question, and columns 2, 3, 4, 5 for the possible answers. You can get information about using SQLite in libGDX here
You could make into some method actor, whom he pass an id to access the SQLite for the question and the answers to that question, then assign some variables, and use a switch statement, if you don't want to have much if-elseif etc.
Note: I think that SQLite is mostly used when you want data to be saved and used in the future; if the data for example change every 10 minutes, I think it would be better to use JSON, because in SQLite making connections to the database every 10 minutes may take some time. I think this is not the case; in my opinion the purpose of JSON and SQLite is completely different. I would use for example:
JSON = I would use it to send or/and receive data betwen server & client or configuration files etc.
SQLite = I would use it to store data.
This is only my opinion, and I not say that SQLite is better or worse than JSON.
PS 1: the photo is taken from the Internet
PS 2: I also believe that you should read https://stackoverflow.com/tour

Categories