• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Quality of code for game controller class

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:I went to an in person university and it didn't prepare me for the OCA either. I don't college is designed to do that. Nor is a job. That's why study guides exist .

That said, when you interview for a job, interviewers will want to see internship experience or a project you did for fun. So signing up for a free github.com account and writing some code (ex: a game) gives you something to talk about at your interview besides school.

If others are struggling and you are doing well, it suggests you have an affinity for the topic. Which is good to have in a career . Learning more is still good though and will help set you apart.



Thank you. I always continue studying certain subjects to improve on my skill set. Thats the reason I am studying for the exam, whilst following your study guide.





Campbell Ritchie wrote:

Jeanne Boyarsky wrote:. . . . I don't [think] college is designed to do that. Nor is a job. That's why study guides exist .

No, the cert exams test knowledge completely different from what you learn at University and also different from what you use on the job. Somebody like Liutauras or Tim C will know a lot more than me, but I think people get an entry level job and then work for a cert later, or more frequently, an MSc.
And let's have a “disclosure of interests” about how many cert exam guides you wrote

. . . internship experience or a project you did for fun.

Same on this side of the Pond. Many courses here are four‑year “thick” sandwich courses. That includes a year's internship . . . with a salary attached. The teaching staff visit every student on industrial placement to verify they are still there . . . and to verify that they are being given something wothwhile to do.

. . . you have an affinity for the topic. . . ..

I hope you are right and not that the assignments are set too easy. If GK shows us some code, we can have a look at it and it should be easy to assess its quality.
Open Univrsity is sort of “in person”. Although much of the teaching is delivered via TV the Net, students should meet a supervisor in person regularly and go away for intensive short courses. Maybe that interaction has been lost under CoViD; Universities have been very keen to minimise the risk of appearing on the front page of thee newspaper as, “983645837629856239846593874 CoViD cases at XYZ University”.




The following code snippet is from the wizardcontroller class. This was the final piece of course work at the end of the year, just before the exam.




A part of the question was the following:

The WizardController class has the following private instance variables:
Two variables of type Wizard:
wizard1 and wizard2

which represent the wizards performing the moves;

A variable of type int:
numOfRepeats

which holds the number of times the moves are to be repeated;

It also has three int class constants:

MIN_NUM_REPEATS and MAX_NUM_REPEATS
which hold the minimum and maximum number of times the moves can be repeated.

LAST_CELL
which holds the maximum cell number permitted in the X direction.

The class has a single constructor that takes two arguments of type Wizard and assigns them to the two Wizard instance variables.

You are now going to write the various methods in WizardController that animate the wizards. In order to follow the motion of the wizards properly you will need to slow the animation down. To help you do this we have provided a class method delay() in the WizardController class.

e.g. If you want a delay of 100 ms you would insert the following statement at the appropriate point in your code.:

WizardController.delay(100);
Remember to use delay() at the appropriate point in each of the methods you write to animate the wizards.'

You should remind yourself of methods the Wizard class provides now as you will need to use these in your code.

Remember that you cannot make use of the Wizard method getPersona() within the WizardController class.

i.Write a public class method jump() that returns nothing. It should make the wizard passed as argument jump up one cell position from its current cell then return to its original cell.
Now create an instance of wizard and execute the jump() method passing it as argument to check this works as expected. You'll find code in the README file that will help you with this.

(3 marks)

ii.Next you are going to create a public class method travel() that takes a single argument of type Wizard and returns no value.
The wizard should move left or right as appropriate one cell at a time.

If the wizard's cellX value is currently LAST_CELL it should move so that its cellX value is 0.
Otherwise it should move so that its value is LAST_CELL.
Test your code to make sure the wizard behaves as expected.

(5 marks)

iii.Add an additional boolean argument isMagic to your travel() method, that governs whether the wizard moves straight to its destination or cell by cell in a loop.
Amend the code body of travel() so that for each path, if the argument isMagic is true then the wizard moves straight to its final destination so that cellX is 0 or LAST_CELL as before.

Otherwise the wizard should move as in part (b)(ii).

Test your code to make sure the altered behaviour of the wizard is as expected.

(3 marks)

iv.Write a public class method switchTrack() that takes two arguments of type Wizard and returns no value. The method should switch the cellY values of the two wizards.
(3 marks)

 
Marshal
Posts: 74341
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your constructor is leaving the wizard controller object in an inconsistent state, with too few repeats. Use the same names for the parameters as you did for the fields if you are using the this.xxx = ...; idiom.
Your promptRepeats() method doesn't set the repeats.
Your getRepeats() method shouldn't prompt for corrections. Make your methods each do one thing and one thing only.
Have you been told to use that method for IO? There are better ways to read from the keyboard.
 
Gosse Kooistra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Your constructor is leaving the wizard controller object in an inconsistent state, with too few repeats. Use the same names for the parameters as you did for the fields if you are using the this.xxx = ...; idiom.
Your promptRepeats() method doesn't set the repeats.
Your getRepeats() method shouldn't prompt for corrections. Make your methods each do one thing and one thing only.
Have you been told to use that method for IO? There are better ways to read from the keyboard.



The code I posted in the previous post, is the unfinished code. As I am not allowed to post the completed version due to uni policy. And yes, I must use that method for IO. I got full marks on this specific part of the assignment.
What do you think of the overall level of code? Is this what is expected of a BSc level course, or is it below the expected level?
 
Campbell Ritchie
Marshal
Posts: 74341
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't quote the whole of the preceding post.

Quite a bit above average But, how are you setting how many repeats?
 
Gosse Kooistra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


That was the answer that I came up with, and gave me full marks
 
Campbell Ritchie
Marshal
Posts: 74341
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Afraid I wouldn't have given full marks, though the code is quite good.
You are constrained to use the OpenU input, which makes things difficult for you. The input class doesn't give you input with a specific format, so you have to use Integer.parseInt() on it. It would be preferable to have the input class verify that what you have is an int, but that isn't possible here. You therefore have to write your own code to test whether you have an int. It is possible to design the class to deliver an int. That would also obviate repeating code; if you have multiple fields to update, you will end up writing the same method several times with only minor differences.
I would prefer something else to happen in the catch, like issuing an error message: “...please try again.”
You aren't validating the value of the number entered; it will happily take −87435834 without your being able to do anything about it.
There is no guarantee that this method will be used to update the repeats field. It is usual for setXXX() methods to have void rather than their return type, and to update the appropriate field directly:-If your method doesn't do that, it has no way of “knowing” whether it will be called in such a way as to update the correct field.

I am going to split off the posts containing code to a different forum.
 
Campbell Ritchie
Marshal
Posts: 74341
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Posts split from this Jobs thread. I think I have split one post too many, and shall try to put it back whence it came.

[edit]The incorrectly split post has been returned to its original location, here, whence this thread was split.
 
Gosse Kooistra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looking at your explanation, it makes totally sense. This is the exact kind of feedback I was looking for. I wish my course was more like that and would supply me with more feedback to improve myself. Thanks
 
Campbell Ritchie
Marshal
Posts: 74341
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gosse Kooistra wrote:. . . supply me with more feedback to improve myself. Thanks

That's a pleasure and . . .

Don't know any more about your course. Don't know whether they use real live people to do the marking and supply the feedback, or automated marking. A machine may simply miss what I found. It takes experience to find such problems, though my experience let me find them in a few minutes. It takes a lot longer to write the feedback down, however. I don't know whether you are in a position ot apply for a course elsewhere.
 
Gosse Kooistra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Open University uses real people marking the programming / solution document. They often work part time for the university as lecturers / tutors. Most often they do this besides their careers in the industry, so in theory they should have the experience to find issues.

Unfortunately I am not in a position to apply anywhere else, as I would have to resit a full year, as each university has its own subjects they teach, and they don't always match another university.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic