The Student Room Group

AQA Computer Science 2016 ~ COMP 1 Tasks (VB.net)

Hey there, for anyone struggled with ideas for revision for the AQA Computer Science exam on Battleships coming up on Monday, I have attached a series of example questions they could ask you about the code. An almost certain question they will ask you is to fix the GetRowColumn sub routine to ensure it does not crash when an invalid input has been entered (Understanding try or catch exceptions is not required).

The answers are also there, but I urge you to have a go at programming before you check the answer - remember in the exam there are multiple 'method' marks available.

Best of luck to you all in the exam, if anyone else has any questions about the exam, I also have learnt and understand the program in Python and Java. So feel free to ask any questions or concerns about the COMP 1 (or perhaps COMP 2) exam :biggrin:.

================
P.s. Just a useful tip, for the randomization of the positions on ships, it is not actually initialized in the program, and so in VB.net, all you need to do is add Randomize() into the PlaceRandomShips sub routine
================

Edit: I am currently trying to respond but I still need moderator approval, sorry guys :/
(edited 7 years ago)
do you have any potential questions for the comp2 exam? thanks
Hi, thanks a lot for the questions!

I've tried out your solution to the difficulty problem but found that it doesn't work as if you set the difficulty to hard and attempt to start a game the program will crash because there are still lines in the program that identify positions in the array that doesn't exist, since the array was shortened by ReDim... I'm not sure how to fix it, help would be appreciated!

Thank you
Reply 3
Original post by katiealex99
do you have any potential questions for the comp2 exam? thanks


There is always the specimen questions which are available here. I would recommend having a full go at both Paper 2 Specimen papers, and ensure to learn some key points from the 9 mark questions to help you with the 9 mark question coming in the exam.

Other than that, attached is a collection of past papers for paper 2, along with word documents indicating which questions to do as many from the old specimen no longer apply to our new specimen.

Anything else let me know.
Original post by Nouie
Hey there, for anyone struggled with ideas for revision for the AQA Computer Science exam on Battleships coming up on Monday, I have attached a series of example questions they could ask you about the code. An almost certain question they will ask you is to fix the GetRowColumn sub routine to ensure it does not crash when an invalid input has been entered (Understanding try or catch exceptions is not required).

The answers are also there, but I urge you to have a go at programming before you check the answer - remember in the exam there are multiple 'method' marks available.

Best of luck to you all in the exam, if anyone else has any questions about the exam, I also have learnt and understand the program in Python and Java. So feel free to ask any questions or concerns about the COMP 1 (or perhaps COMP 2) exam :biggrin:.


================
P.s. Just a useful tip, for the randomization of the positions on ships, it is not actually initialized in the program, and so in VB.net, all you need to do is add Randomize() into the PlaceRandomShips sub routine
================

Thank you so much for uploading this! I really appreciate this!!!!

Original post by nikthepolarbear
Hi, thanks a lot for the questions!I've tried out your solution to the difficulty problem but found that it doesn't work as if you set the difficulty to hard and attempt to start a game the program will crash because there are still lines in the program that identify positions in the array that doesn't exist, since the array was shortened by ReDim... I'm not sure how to fix it, help would be appreciated!Thank you


Since the solution in the answer document didn't randomize the ships but rather the position, I may be able to post my solution here.

I just declared a difficulty variable and set it initially to 2 (2 being normal) and going from there tbh. Works as intended. May lose marks cause it's not the efficient way of doing it and it doesn't randomize the ships so you're always gonna get that 1 type of boat etc.
Original post by TheTechnoGuy
Thank you so much for uploading this! I really appreciate this!!!!



Since the solution in the answer document didn't randomize the ships but rather the position, I may be able to post my solution here.

I just declared a difficulty variable and set it initially to 2 (2 being normal) and going from there tbh. Works as intended. May lose marks cause it's not the efficient way of doing it and it doesn't randomize the ships so you're always gonna get that 1 type of boat etc.



Ah thank you!

I don't think you lose any marks in the exam for being inefficient, I thought as long as it works you get full marks :smile:
Original post by nikthepolarbear
Ah thank you!

I don't think you lose any marks in the exam for being inefficient, I thought as long as it works you get full marks :smile:

yep, I hope so - I just hope it's a nice exam, last few have been nasty. Maybe because this is a new spec, they may be nice haha
Is this alright for question 2?
Sub MakePlayerMove(ByRef Board(,) As Char, ByRef Ships() As TShip)
Dim Row As Integer
Dim Column As Integer
Dim n As Integer = 0
GetRowColumn(Row, Column)
If Board(Row, Column) = "m" Or Board(Row, Column) = "h" Then
Console.WriteLine("Sorry, you have already shot at the square (" & Column & "," & Row & ":wink:. Please try again.":wink:
ElseIf Board(Row, Column) = "-" Then
Console.WriteLine("Sorry, (" & Column & "," & Row & ":wink: is a miss.":wink: Board(Row, Column) = "m"
Else
For n = 0 To 4
If Board(Row, Column) = Mid(Ships(n).Name, 1, 1) Then
If Ships(n).Size > 0 Then
Ships(n).Size -= 1
Else
Console.WriteLine("You sunk the " & Ships(n).Name)
End If
End If
Next
Console.WriteLine("Hit at (" & Column & "," & Row & ":wink:."
Board(Row, Column) = "h"
End If End Sub


<3 <3 thank you!!
Reply 10
Anyone know how to do the torpedo in VB, the wikibook only has python and java ?
Reply 11
Sub PlayGame(ByVal Board(,) As Char, ByVal Ships() As TShip)
Dim GameWon As Boolean = False
Dim TorpedoUsed As Boolean = False
Dim TorpedoChosen As Char
Do
PrintBoard(Board)
If Not TorpedoUsed Then
Console.Write("Fire a torpedo? (Y/N)")
TorpedoChosen = Console.ReadLine()
End If
If TorpedoChosen = "Y" Then
MakePlayerTorpedoMove(Board, Ships)
TorpedoChosen = "N"
TorpedoUsed = True
Else
MakePlayerMove(Board, Ships)
End If
GameWon = CheckWin(Board)
If GameWon Then
Console.WriteLine("All ships sunk!":wink:
Console.WriteLine()
End If
Loop Until GameWon
End Sub

Sub MakePlayerTorpedoMove(ByRef Board(,) As Char, ByVal Ships() As TShip)
Dim Row As Integer
Dim Column As Integer
GetRowColumn(Row, Column)
While Row > 0 And (Board(Row, Column) = "m" Or Board(Row, Column) = "-":wink:
Board(Row, Column) = "m"
Row = Row - 1
End While
If Board(Row, Column) <> "-" And Board(Row, Column) <> "m" Then
Console.WriteLine("Torpedo hits at (" & Row & "," & Column & ":wink:":wink: Board(Row, Column) = "h"
Else
Console.WriteLine("Torpedo failed to hit a ship":wink: Board(Row, Column) = "m"
End If
End Sub
(edited 6 years ago)

Quick Reply

Latest

Trending

Trending