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 trialAurelian Spodarec
7,369 PointsHow to post code on Treehouse forum
Hi everyone!
Heres how you post code to treehouse and more :)
Markdown Cheatsheet
Markdown is a short-hand syntax for easily converting text to HTML. Below are some popular examples of Markdown formatting. For more examples reference Markdown Basics for a more detailed overview.
Links
This is an [example link](http://example.com/)
Code
Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.
```html
<p>This is code!</p>
```
Italic
Hereβs a word that is *emphasized*
Bold
Hereβs a word that is **bold**
Images
![alt text](/path/to/img.jpg "Title")
Unordered List
+ Candy
+ Gum
+ Peanuts
Ordered List
1. Red
2. Green
3. Blue
2 Answers
Aurelian Spodarec
7,369 PointsI would also recommend :
https://teamtreehouse.com/forum/howto-guide-markdown-within-posts
and
https://teamtreehouse.com/forum/posting-code-to-the-forum
Have fun!
Marty scheid
1,589 Points'''
public class Game {
private String mAnswer;
/// final means cannot be changed alcaps MAS_MISSES means constant\\\
public static final int MAX_MISSES =7;
private String mMisses;
private String mHits;
//constructor\\
public Game(String answer) {
mAnswer = answer;
mHits = "";
mMisses = "";
}
// private method\\
private char validateGuess (char letter) {
if (! Character.isLetter(letter)) {
throw new IllegalArgumentException("A letter is required");
}
letter = Character.toLowerCase(letter);
if (mMisses.indexOf(letter) >= 0 || mHits.indexOf(letter) >=0) {
throw new IllegalArgumentException(letter + "has already been guessed");
}
return letter;
}
///method\\
public boolean applyGuess(char letter) {
letter = validateLetter(letter);
boolean isHit = mAnswer.indexOf(letter) >=0;
if (isHit) {
mHits += letter;
} else {
mMisses += letter;
}
return isHit;
}
public String getCurrentProgress() {
String progress ="";
for (char letter: mAnswer.toCharArray()) {
char display = '-';
if (mHits.indexOf(letter) >= 0) {
display = letter;
}
progress += display;
}
return progress;
}
public int getRemainingTries() { return MAX_MISSES - mMisses.length(); }
}
'''
Konrad Pilch
2,435 PointsThe brackets need to.start on a new line.
Konrad Pilch
2,435 PointsAlso, the brackets are wrong. They need to be back-ticks, not front-ticks. ``` this
So i assume this is ios.
You would need
``` objectice-c (i think)
code
```
Aurelian Spodarec
7,369 PointsAurelian Spodarec
7,369 PointsHeres a screenshot :
http://scr.hu/2icp/g6imy