Win a copy of Head First Android this week in the Android forum!

Daniel Castellano

Greenhorn
+ Follow
since Nov 06, 2015
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel Castellano

Campbell Ritchie wrote:Why are you combining a switch and an if?

I think you need to think again. Are you supposed to enter 7 cities with populations? Do you have a City class? With name and population as fields?
Why are you using option panes rather than a Scanner?



You're right. I realized that they are redundant the moment i finished to post.

I am supposed to ask the user which city he wants the population to be added and then print the totals of each city. I do not have a City class. And because we are supposed to use OptionPane for this one.


EDIT:



Using this code in Case 1. It is working so far, i can obtain the number of people living in City 1 and the print the total value of the people living in there. However i can add a maxium of 8 values(because my array is of 8 thinking of the 7 cities).

But the thing is that i want to add the values of people living in City 1 in just the index 0 of my array. I'm not sure if that possible without using an array of array. Or should i use an array for each city?

To clarify: city.getInfo comes from City class, that method is used to obtain and store the value of the city population.
6 years ago
Hi guys, i have an assignment in which the user is asked for the number of city he would like to access, and when he does, he inserts the number of people living in it. The thing is i'm supposed to save the number of people living in each city in an array and then print all of them.

I have this so far,



Alright, i'm using case to access the "city" the user wants, it is probably poorly used and the "if" inside of it is redundant.

The other problem i'm having is that i have no idea how to insert the value of people living in certain city inside of certain index. For example i want to store the people living in city 1 inside the index 0 of the array, and so on. Any help would be appreciated. I'm trying to learn as much as i can and i'm researching on how to do it but i would like some help as well.
6 years ago

Campbell Ritchie wrote:The problem is that you only have the parts and you have to look at the whole. You need a plan, either on screen or on paper or in your head.

Consider a quiz. Remember how it works. You ask competitors questions and they get marks (or otherwise) for answers. You appear to have classes for the questions and the time, but do you have classes for the whole quiz or the competitors?



Oh yes, the Question class involves both, questions and answers. Besides the time there is the Frame time for everything related to the interface of the game(however i'm testing it on the console itself). I have a Level class that will check the advance of the player(5 questions each level) and finally the User class.

6 years ago
Hey guys,

I'm new to the forum and programming in general. Currently on week 9 of Java lessons and i've been told to made a "game" for week 15, and i picked some sort of Quiz Up clone.

The thing is i'm not sure about one thing, for example i have a class called Question and another class called Time. So basically whenever the user picks a wrong answer, the question is passed and -5 seconds of the total time are substracted. If the user picks the correct answer then +5 seconds are added to the total time.

I have my question class with a method to check the answers and but i haven't done the time thing in the Time class because i don't know how to connect the choices made my the user in Question class to a method that adds and substract seconds in another class.

6 years ago