Presentation is loading. Please wait.

Presentation is loading. Please wait.

MSc IT Programming Methodology (2). Word so far: ??? Guess a character: Assume the word is POP.

Similar presentations


Presentation on theme: "MSc IT Programming Methodology (2). Word so far: ??? Guess a character: Assume the word is POP."— Presentation transcript:

1 MSc IT Programming Methodology (2)

2

3 Word so far: ??? Guess a character: Assume the word is POP

4 Word so far: ??? Guess a character: E

5 Word so far: ??? Guess a character: E Number of Es in word: 0 Word so far: ???

6 Word so far: ??? Guess a character: E Number of Es in word: 0 Word so far: ??? Guess a character:

7 Guess a character: E Number of Es in word: 0 Word so far: ??? Guess a character: P

8 Word so far: ??? Guess a character: E Number of Es in word: 0 Word so far: ??? Guess a character: P Number of Ps in word: 2 Word so far: P?P Keep going until they guess the word

9 To pass the coursework you must implement this basic program by developing a suitable Game class.

10 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean

11 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean The word to guess, e,g “POP”

12 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean An array of characters that represents the word guessed so far.

13 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean Constructor receives the word to guess (e.g. “POP”) and initialises the String and the array..

14 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean The size of the array soFar will be set to the size of the String word.

15 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean So if the word to guess is “POP” the soFar array will be size 3.

16 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean Initially each character in the soFar array will just be a question mark (‘?’)

17 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean This method returns the secret word.

18 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean This method returns the soFar array represented as a SINGLE String.

19 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean HINT!!

20 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean There is a String constructor that converts an array of characters into a String

21 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean E,g: String someString; someString = new String(soFar);

22 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean Method takes a character and returns the number of occurrences of that character in the secret word.

23 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean If the word was “POP”: guess(‘P’) == 2

24 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean Check your String methods to find out how to do this.

25 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean The method also updates the soFar array. So if the word was POP you would get : ‘P’,‘?’, ‘P’

26 To pass the coursework you must implement this basic program by developing a suitable Game class. Game String word char[ ] soFar Game(String) getWord():String getWordSoFar(): String guess(char): int gameOver(): boolean This method returns TRUE if the game has finished (the word in soFar equals the secret word).

27 ENHANCEMENTS Limit the number of guesses the user can have to guess the word. You should try and use INHERITANCE to add this extra functionality. Develop a GUI for this application rather than a text based interface.

28 MAKE SURE YOU… Hand in a disc with all your.java files (source code) Hand in a program listing Hand in a short user manual describing how to run your program.


Download ppt "MSc IT Programming Methodology (2). Word so far: ??? Guess a character: Assume the word is POP."

Similar presentations


Ads by Google