Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTomas Verblya
1,998 PointsRegarding the Vending machine code
So, as I am watching these tutorials, I seem to have found myself at a small crossroads.
What I mean is: I cannot follow the Vending machine code, especially the chooser classes. I can kind of grasp the code, but not comfortably enough. Now I'm going through the videos, and Craig seems to assume that we either know this code, or he just wants us to bear with him and follow him along and only care about the JUnit stuff.
So, I came here after the Learn Java course, and I seem to be needing extra info/studying in to the vending machine code. S
Should I focus on the JUnit stuff, or should I try to analyze the vending machine code first?
2 Answers
Chris Collier
17,774 PointsI'm in the same place, and I definitely think that you're correct when you say that he wants us to bear with him. I saw a webcomic about learning to code that talked about the stages of coding and I think the final stage was something like "I don't know everything, but that's ok", and I think that's the point they're trying to drive home here. How have you been doing in the two months since you posted this question? Feeling any better?
angel juarez
15,886 PointsYes, thank you. I've been learning more, I have still a lot to learn, but that's why I'm here studying.
Jordan Powell
Courses Plus Student 5,410 PointsYou really have to examine the code to understand
@Override
public Location locationFromInput(String input) throws InvalidLocationException {
Pattern pattern = Pattern.compile("^(?<row>[a-zA-Z]{1})(?<column>[0-9]+)$");
Matcher matcher = pattern.matcher(input);
if (!matcher.matches()) {
throw new InvalidLocationException("Invalid buttons");
}
using the pattern object to organize the references as B4 or A1 like you see in an actual vending machine. You set the rows in your test to 26 because its the length of the alphabet and columns are set to 10 because it's between 0-9. Our test method is checking to see if "B4" is within those parameters. if you were to put "B11" in the locationFromInput method the test would fail. However, I think you should just focus on the testing portion. He is showing when two asserts methods may be necessary and additionally how you can add an optional assertion message to clarify which item is being referenced.
angel juarez
15,886 Pointsangel juarez
15,886 PointsI'm learning too, I think that you should focus on the JUnit first. For the java code, I suggest you to check the java track if you haven't done it, and also you can try to use the debbuger to check how the code works.