AQA Comp1 Exam !!!

Hi guys,

i see there's no thread on this, in the visual basic sect, so i though i would create one.

The idea is that we can start posting code and helping each other out.

I for one am stuck on how to allow a user to make a complete guess...


LETS GET THIS THREAD GOING, IT WILL BENEFIT ALL OF US..

THANKS

Comments

  • i have figured out how to [b]input and read from the file[/b], if anyones interested just let me know....



  • Im pretty screwed atm lol , anybody know how to get the data file imported so that you can do a single player game with a random word generated from the list?
  • I can help you, POst your code so far.... and i will let you know..
  • Hi new to this site, I rly need help in this area and I was wondering do you think they will ask to make the input all upper case characters for the inputbox? and is it even possible? plus stuck with all the other things mentioned above. I'm using VB6 Express edition
  • A user posted some edit pascal code for his hangman and iv been converting it to Visual basic manually. But iv come across some problems. 1 the text data import and some other commands such as (LettersGuessedArray[Ord(UpCase(GuessedLetter))-64])
    Im looking to be able to enter the word all at once and win staight way and also have a validation that tells the user they have already guessed the letter.
    anyway heres the code so far:




    Module Module1

    ' Skeleton Program code for the AQA COMP1 Summer 2009 examination
    ' this code should be used in conjunction with the Preliminary Materials
    ' written by the AQA COMP1 Programmer Team
    ' developed in the Visual Basic 2005 (Console Mode) programming environment
    ' the DisplayMenu procedure has deliberately omitted a menu choice 3 and 4

    Dim NewPhrase As String
    Dim PhraseHasBeenSet As Boolean
    Dim PhraseGuessed As Boolean
    Dim Choice As Integer
    Dim IndividualLettersArray(20) As Char
    Dim GuessStatusArray(20) As Char
    Dim LettersGuessedArray(26) As Char
    Dim NextGuessedLetter As Char
    Dim Index As Integer
    Dim completeguess as string
    Dim datafile as text
    Dim randomphrases[100] as string
    Dim numberofphrases as integer
    Dim guesses as integer


    Sub DisplayMenu()
    Console.WriteLine("__________________________________")
    Console.WriteLine("")
    Console.WriteLine("1. SETTER - Makes new word/phrase")
    Console.WriteLine("")
    Console.WriteLine("2. USER - Next letter guess")
    Console.writeline(
  • This is my code, it works perfectly for VB 2003 language, which is what we use at my school.

    All of the preliminary tasks have been completed;

    Array to store letters
    Guess a whole word
    Open MyPhrases.txt file and use random number generator to select a line.


    Hope This Helps =)




    Option Explicit On
    Imports System.IO


    Module Module1


    Dim ArrayPosition As Integer = 1
    Dim NewPhrase As String
    Dim LineText As String
    Dim PhraseHasBeenSet As Boolean
    Dim PhraseGuessed As Boolean
    Dim Choice As Integer
    Dim IndividualLettersArray(20) As Char
    Dim GuessStatusArray(20) As Char
    Dim LettersGuessedArray(26) As Char
    Dim NextGuessedLetter As Char
    Dim NextGuessedWord As String
    Dim Index As Integer


    Sub DisplayMenu()
    Console.WriteLine("")
    Console.WriteLine("-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-")
    Console.WriteLine("")
    Console.WriteLine("1. Player 1/SETTER - Makes New Word/Phrase")
    Console.WriteLine("2. Player 2/USER - Guess An Inidividual Letter")
    Console.WriteLine("3. Player 2/USER - Guess Whole Word")
    Console.WriteLine("4. Player 1/SETTER - Import Text File Of Random Words")
    Console.WriteLine("5. END")
    Console.WriteLine("")
    Console.WriteLine("-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-")
    Console.WriteLine("")
    End Sub


    Sub Main()
    PhraseHasBeenSet = False
    Do
    Call DisplayMenu()
    Console.WriteLine("Menu Choice: ")
    Choice = Console.ReadLine
    If Choice = 1 Then
    NewPhrase = GetNewPhrase()
    SetUpGuessStatusArray(NewPhrase, IndividualLettersArray, GuessStatusArray)
    PhraseHasBeenSet = True
    End If


    If Choice = 2 Then
    If PhraseHasBeenSet = True Then
    DisplayCurrentStatus(Len(NewPhrase), GuessStatusArray)
    NextGuessedLetter = GetNextLetterGuess()
    For Index = 1 To Len(NewPhrase)
    If NextGuessedLetter = IndividualLettersArray(Index) Then
    GuessStatusArray(Index) = NextGuessedLetter
    End If
    Next
    DisplayCurrentStatus(Len(NewPhrase), GuessStatusArray)
    PhraseGuessed = AllLettersGuessedCorrectly(GuessStatusArray, NewPhrase, _
    IndividualLettersArray)
    If PhraseGuessed = True Then
    Console.WriteLine("You Have Guessed Correctly")
    End If
    Else
    Console.WriteLine("The Setter Has Not Specified The Word/Phrase...")
    End If
    End If


    If Choice = 3 Then
    If PhraseHasBeenSet = True Then
    NextGuessedWord = GetNextWordGuess()
    If NextGuessedWord = NewPhrase Then
    Console.WriteLine("You Have Guessed Correctly")
    Else
    Console.WriteLine("You Have Guessed Incorrectly")
    End If
    End If
    End If


    If Choice = 4 Then
    Call UseFile()
    NewPhrase = LineText
    SetUpGuessStatusArray(NewPhrase, IndividualLettersArray, GuessStatusArray)
    PhraseHasBeenSet = True
    End If


    If Choice = 5 And PhraseGuessed = False Then
    Console.WriteLine("Phrase Has Not Been Guessed, Press Enter To Confirm Exit..")
    Console.ReadLine()
    ElseIf Choice = 5 And PhraseGuessed = True Then
    Console.WriteLine("Phrase Has Been Guessed, Congratulations, Press Enter To Exit...")
    End If
    Loop Until Choice = 5
    End Sub


    Function GetNewPhrase() As String
    Dim PhraseOK As Boolean
    Dim ThisNewPhrase As String
    Do
    Console.WriteLine("Key In The New Phrase
  • You are a lifesaver Thundrle. This has helped me big time and it is much appreciated. Is this from the actually AQA comp1 test material?
    Now all I have to do is revise this code :S. Cheers again.
  • Haha, that's quite alright
    It is the original code from the preliminary release but with the necessary tweeks to complete the possible tasks.
    You need to remember those examples might not be the questions in the actual exam. They are more like guides :)
  • yeh i know but, all the signs (comments) suggest that they are the questions that will be asked. And my teacher has made a task sheet for practice exactly to what you have done so it seems pretty obvious. iv compared your code to the original code and highlighted the code you have entered. now im going just going to revise it. my exam is tomorrow morning so hope i remember it all, theres not that much. thanks vice.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories