Tyson Lindner

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

Recent posts by Tyson Lindner

Simple typo on lines 55 and 56, I'm assuming you're trying to set values there instead of get them.* Anyway you should probably have a Map or something for usernames and passwords. You don't need a separate class for just a username and password entry, even though you might need the Driver class for some reason after access has been granted.

*edit: also your set methods have parameters that aren't used.
7 years ago

ekte spiriopoulos wrote:can i add methods?



Its more like you're adding/storing the results of those methods.
7 years ago

Kawita Kandpal wrote:
At present, I don't actually know how to compute a number in reverse, so I've got a date with Google.



Another way to think about it is that when you reverse a number you're really just reversing the representation of that number (the Arabic numerals). So really you don't have actually have to do any mathematical computation at all you can just manipulate a String. That can actually be achieved with just one line of code (not through String class though). You still might have some work to do though depending on what you're allowing for valid input/output. For example, will the reverse of 4000 output 0004 or just 4? How do you want to handle a negative sign?
8 years ago
Well yeah, you need at least one while loop. The basic idea is that you're asking a certain question until you get a certain answer, at that point the loop stops cycling. In other words while you aren't getting the password to match, you keep asking for the password. Or, while the user does not want to exit the program, you keep asking for their first and last name.
8 years ago
I'd be curious to see how actual tax software implements this sort of thing, but since you're generally asked about marital status early on you're probably looking at two completely separate blocks of code for either single or married. That would require you to repeat code to some extent but I think for this case it would make things a lot less confusing and also make it easier to add the ability to handle random features of tax law that affect just single or just married people.
8 years ago
You should have an array of permutations which should be completely separate from the logic used to output that array.

Regular System.out.print() is your friend - not System.out.println(). So for all the characters except the last for a given line use System.out.print(value + ","), then just System.out.print(value) for the last character and then add a newline character or just use System.out.println();
8 years ago
If you're recording three different medal types you would need at least three different arrays for each medal (int[] bronze, int[] silver, int[] gold, and maybe int[] total). You don't have to loop through your medals in any way while you're looping through your countries.

Parallel arrays can get really messy, if you're capable of using an object oriented approach you should do so.
8 years ago
Are you sure this isn't an exercise in using REGEX? I don't see another good reason why your instructor would make things unnecessarily difficult for you here. Also, toCharArray() is a String method so that might not even be legal. You might have to read the file character by character to begin with because getting a String and not being allowed to do anything with it isn't going to help you.

If you do decide that getting a character array is legal/best, then it looks like you're on the right track, but you've made things way too complicated by adding a separate class and using class fields. Its probably best to have multiple static methods that take your main array as an argument and have them each return the appropriate smaller array. It might be easier to use ArrayList<Character> so you don't have to worry about knowing the size ahead of time and it also allows you to use the indexOf() to quickly find the endpoint of the data you're trying to extract.
8 years ago
I have a row of images that I want aligned in the center of the page. The images are of different sizes, but I want them to fit inside boxes with a larger fixed size. With the code right now, the boxes become displaced due to the size of the image meaning they're shifting underneath the row they're supposed to aligned on.



One trick you can use is to add all your items to a set and then check the length of the set in order to see how many different values there are. From there you only have to decide between a few different hand values. For example if you only have two different values you either have a full house or four of a kind (which should really be treated as a completely separate value not part of "triple"), so all you have to do is check how many instances you have of one of those values. If its 2 or 3 you have a full house, otherwise its four of a kind.
8 years ago

Stephan van Hulst wrote:

Tyson Lindner wrote:In programming parsing is more the creating of something based on something else.


Not just something else. Parsing refers specifically to creating an instance of some type out of textual data.



Honestly it feels like the word always gets used in that context but I don't think it absolutely has to be used that way. For example if someone has an audio file of someone speaking a list of names and numbers we would still "parse" that file to get those values even if we aren't using some built in parse method.


Text means nothing if you don't attach meaning to it. Parsing attaches meaning to textual data.



See I feel like the data already has meaning. For example we would say the string "Apple" has meaning because it relates a known everyday object. So we could also say that "two" has meaning or that "2" has meaning. When we're "parsing" one of the latter values all we're really doing is converting it to another format.
8 years ago

Ahmad Auada wrote:I searched for this on google, most answers tend to say this :
Parsing means reading text and deciding what the different parts of it mean. In the case of methods like Integer#parseInt(String) it needs to work out what the whole of the text means.



That seems like more of a non-programming definition of parsing since "meaning" is so ambiguous. In programming parsing is more the creating of something based on something else(for example the creation of an integer based on a String). Casting on the other hand is more like deciding what to call something, is my car a Honda Civic, vehicle, or just a car?
8 years ago

Knute Snortum wrote:I'm not sure this is the best advice for a beginner. They should learn to build and use classes as much as possible for all but the simplest programs (three or four lines). Classes are much easier to debug and maintain and once you get the hang of it, and I think they are easier to program with too.



I generally agree with what you're saying, just for specifically the card and board I don't like creating classes. The project as a whole should have several other classes and give plenty of practice.
8 years ago
I've actually had a memory game project before although the features were drastically simplified compared to what it seems like you are doing. As people have hinted at, your version is a pretty involved project and its good that you have about a month. Still, the bulk of the project is actually the graphical user interface. Its difficult to display images correctly in a grid-like layout and be able to process mouseclicks in the appropriate manner. In the initial phase of just setting up how your program might work without a GUI it looks like you might be overthinking your project. Honestly a card class and a board class aren't even really necessary. All you're doing is comparing multiple cards for equivalency, the cards themselves don't really have any sort of functionality. Your board is really just an array of cards, there isn't anything the board itself does. The tricky part is later that you have to keep track of what cards are appropriately face up and face down to be displayed graphically, but you really don't need specific classes to do this, just some sort of array-like data structure. Of course its OK to have a Card and Board class if that makes it easier to conceptualize things (or its required by the assignment for some reason), but at the very least you should take some strong consideration into what methods those classes actually need (not very many, and possibly even zero). To do all this I think its better to think of adding 26 different objects to the array twice, instead of adding 52 different objects.
8 years ago
I actually think the reasoning to avoid getters and setters somewhat applies here. Well, not for getters. I have no problem with every attribute in your CharacterClass class to be paired with a simple getter. With setters on the other hand its a different matter. We don't really want to be using simple code to just "set" our attributes to a certain level. We should have rather complicated methods to do so that take other game states into account. For example, say we take damage from a goblin. That goblin might have an attack power of 3, and if our life is 10, we might be tempted to call a method setLife(7), but the code for that logic has to actually go somewhere and its possible we can have a lot more variables. For example we might have leather armor that reduces attack damage by 1, and a shield ward that also reduces it by 1. Its much better to have and call an internal method takeDamage(3) that takes into account our armor, wards, magic amulets, etc. that correctly calculates and increments our life loss/gain (1 in this case). Another example would be leveling up. Instead of calling setLevel(8), we should be calling gainXP(*some value*) which may call levelUp(), the latter method being a complicated one that increments all our attributes according to some algorithm. The point is that our character attributes shouldn't be randomly set or incremented throughout the game. We should have events that happen which are handled by our character class which then sets the values internally according to some methodology.
8 years ago