We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Simulating the card game: War

I recently applied for a PHP programming job and they required me to do a coding challenge. One of the challenges involved simulating the card game war which I found intriguing. I "over-engineered" it as they requested, but I still don't think it was good enough for them. Is there anything I could have done better?

A live example is here: http://dev.lifeboatcreative.com/war/index.php

The rules this game is based off are found here: http://www.pagat.com/war/war.html

Source files are attached.

Attachments war-v1.1_.zip (90.13KB)
4
Contributors
8
Replies
1 Month
Discussion Span
9 Months Ago
Last Updated
12
Views
kkeith29
Nearly a Posting Virtuoso
1,388 posts since Jun 2007
Reputation Points: 250
Solved Threads: 202
Skill Endorsements: 6

the lifeboat link goes to a blank page

diafol
Keep Smiling
Moderator
10,838 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,534
Skill Endorsements: 61

I tested the link before posting and it worked. Still does for me....

kkeith29
Nearly a Posting Virtuoso
1,388 posts since Jun 2007
Reputation Points: 250
Solved Threads: 202
Skill Endorsements: 6

Works now! May have been my system.

Ok, has a cursory look at the code. Seems OK - all OOPed.
However - I would have challeneged them with regard to PHP and told them it was a JS solution that would have been more appropriate. :(
For PHP post, I doubt whether they'd worry too much about the front end - but that's the only thing that I'd have maybe tweaked. How long did this take you to write? Were you under 'Hugh Jackman in Swordfish'-like conditions? :) Did they give you any feedback at all?

//EDIT
Like I said, the frontend - CSS: maybe use a single image sprite as opposed to individual images for all cards. Maybe some JS animations as the wars are a little abrupt.

diafol
Keep Smiling
Moderator
10,838 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,534
Skill Endorsements: 61

Javascript would have been better suited for this, I agree, but it was a php challenge.

The front-end was thrown together pretty fast. I wanted to have an elaborate javascript based card animation, but that would have taken too long. A sprite for the cards was in the works, but it would have taken forever to finish creating the image and then coding all the positions into a css file, so I gave up.

They said it should take 2-4 hours, which I found was not possible for me. Maybe I just work slow, but it took 8-10 hours to complete.

They didn't give me any feedback. I was hoping for some either way, but they never responded.

kkeith29
Nearly a Posting Virtuoso
1,388 posts since Jun 2007
Reputation Points: 250
Solved Threads: 202
Skill Endorsements: 6

I really sympathise KK - I couldn't have produced anything that worked that well in 8-10 hours. 2-4 hours suggest that they were looking for soemthing REALLY simple. perhaps, as you mentioned, you over-engineered it - I noticed the template system. Seems you threw the kitchen sink at it - maybe this was the reason? Dunno. Either way - thanks for sharing the code - should be really useful for the rest of us plebs!

diafol
Keep Smiling
Moderator
10,838 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,534
Skill Endorsements: 61

Hello, I'm looking at your code and noticed it's not really up to PHP 5 standards and that's probably why they didn't choose you?

masterdeveloper
Newbie Poster
2 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

it's not really up to PHP 5 standards

Care to elaborate?

pritaeas
Posting Prodigy
Moderator
9,534 posts since Jul 2006
Reputation Points: 1,194
Solved Threads: 1,494
Skill Endorsements: 98

Nevermind. Started really looking into it and saw he did all that. Why wouldn't they hire you? Maybe it was overtkill.

masterdeveloper
Newbie Poster
2 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0788 seconds using 2.68MB