| Pages: 1 :: [one page] |
| Author |
Thread Statistics | Show CCP posts - 2 post(s) |

Umad Bro Questionmark
modro ROMANIAN-LEGION
23
|
Posted - 2011.09.22 02:27:00 -
[1] - Quote
Hey there. Posting from mobile and I got my post eaten due to timeout 3 times no so I'm reaching the end of my patience. Also I can't access out of pod so I'm sorry in advance for posting this here. I got a quick question and I'm grateful for any help anyone might offer regarding my issue:
I need to create a class that takes the parameters length and width and after doing so it finds out whether it's a square or not.
If it is, it then calculates its area/surface (length * width). And there seems to be a trick regarding the parameters but I can't seem to figure it out.
Any help would be greatly appreciated. Thank you for the help and/or good troll attempts.
STUPID FORUM TIMEOUT. FIX THE POST EATING ISSUE PLEASE!!! -á(\ /) -á(-¦ .-¦) -á-áGÖÑ-á-á-á +å+Ñn++ n+ëGêÜ+Ñn¦Ä +¦ c(GÇ¥)(GÇ¥) Crack bunny - will Like for drugs (because its e-peen is already big enough). |

The Apostle
The Black Priests
39
|
Posted - 2011.09.22 02:32:00 -
[2] - Quote
This any help
http://pastebin.com/KEZVUXU0 Take an aspirin. If pain persists consult your local priest. |

Umad Bro Questionmark
modro ROMANIAN-LEGION
23
|
Posted - 2011.09.22 02:57:00 -
[3] - Quote
I love you. Ty! -á(\ /) -á(-¦ .-¦) -á-áGÖÑ-á-á-á +å+Ñn++ n+ëGêÜ+Ñn¦Ä +¦ c(GÇ¥)(GÇ¥) Crack bunny - will Like for drugs (because its e-peen is already big enough). |

Umad Bro Questionmark
modro ROMANIAN-LEGION
23
|
Posted - 2011.09.22 03:13:00 -
[4] - Quote
Ok I get the part where it grabs the sides and calculates the area but 2 questions:
1. what's the deal with that 15 there. Did you mean 25 which would be the result of 5 *5?
2. Is there any piece of code there that actually checks if the sides are equal (aka being a square?) or any other way of determining the shape of the object? -á(\ /) -á(-¦ .-¦) -á-áGÖÑ-á-á-á +å+Ñn++ n+ëGêÜ+Ñn¦Ä +¦ c(GÇ¥)(GÇ¥) Crack bunny - will Like for drugs (because its e-peen is already big enough). |

The Apostle
The Black Priests
39
|
Posted - 2011.09.22 03:36:00 -
[5] - Quote
I suspect the numbers used are hard-coded for readability. (Any programmer will tell you) NEVER to hard-code numeric values. Always pass or declare predefined vars. (EDIT unless they are constants like Pi/SoL etc.)
I can't answer Q2 without knowing what vars are available. If I can assume W and L, then it's a simple if {} construct to determine if it's a square.
I'm rusty on PHP so any other assist from other forum members would be good. Take an aspirin. If pain persists consult your local priest. |

Mr M
Agony Unleashed Agony Empire
9
|
Posted - 2011.09.22 05:41:00 -
[6] - Quote
Someone should've done their homework in time 
|

The Apostle
The Black Priests
41
|
Posted - 2011.09.22 05:46:00 -
[7] - Quote
Quote:Someone should've done their homework in time It reminds me of when I use to lecture in programming. I always gave my phone number to students to contact me if they got stuck on assignments.
Had a call at 3.00am from a student saying he was stuck on Question x.
I was pretty nasty reminding him what time it was.
His reply. "You set the deadline!".
I failed him. Take an aspirin. If pain persists consult your local priest. |

Tippia
Sunshine and Lollipops
181
|
Posted - 2011.09.22 06:16:00 -
[8] - Quote
class rect { private $w; private $l; function __construct($length, $width) { $this->l = (int) $length; $this->w = (int) $width; } function isSquare() { $this->w === $this->l ? return $this->w*$this->l : return FALSE; } }
GǪor some such. I just realised I haven't touched PHP in years, so I'm sure it'll break something.  GÇöGÇöGÇö GÇ£If you're not willing to fight for what you have in GëívGëí you don't deserve it, and you will lose it.GÇ¥ GÇö Karath Piki-á |

DeBingJos
T.R.I.A.D
90
|
Posted - 2011.09.22 08:18:00 -
[9] - Quote
[code] class SquareThingy{ private $length; private $width;
function __construct($length, $width){ $this->length = $length; $this->width = $width; }
// Call this to check if the object is a square function IsSquare(){ if ($this->length == $this->width) return true; else return false; }
// Call this to get the area function GetArea(){ return $this->length * $this->square; } } [/code]
How to use this?
Construct the object $object = new SquareThingy(4, 8); // 4 is length, 8 is the width
$object->IsSquare() // Gives true or false
$object->GetArea() // Gives the area Fix FW ! |

Abdiel Kavash
Paladin Order Fidelas Constans
34
|
Posted - 2011.09.22 12:13:00 -
[10] - Quote
The Apostle wrote:Quote:Someone should've done their homework in time It reminds me of when I use to lecture in programming. I always gave my phone number to students to contact me if they got stuck on assignments. Had a call at 3.00am from a student saying he was stuck on Question x. I was pretty nasty reminding him what time it was. His reply. "You set the deadline!". I failed him.
You're not alone. I am usually pretty specific with deadlines, saying "Jan 15th 23:59", so there's no confusion. Every single time I get three submissions between 23:00 and midnight, often at least one after 23:55. |

Messoroz
AQUILA INC
10
|
Posted - 2011.09.22 12:26:00 -
[11] - Quote
What all you failed at is providing proper set methods for the arguments in the constructor. |

Efraya
12
|
Posted - 2011.09.22 12:56:00 -
[12] - Quote
I <3 the eve forums. Nowhere else would you get this sort of response on a game communities main board.
WSpace; Best space. |

Tippia
Sunshine and Lollipops
186
|
Posted - 2011.09.22 13:07:00 -
[13] - Quote
Messoroz wrote:What all you failed at is providing proper set methods for the arguments in the constructor. GǪnot part of the spec  GÇöGÇöGÇö GÇ£If you're not willing to fight for what you have in GëívGëí you don't deserve it, and you will lose it.GÇ¥ GÇö Karath Piki-á |
|

CCP Zymurgist
C C P C C P Alliance
130

|
Posted - 2011.09.22 14:33:00 -
[14] - Quote
Moved from General Discussion. Zymurgist Community Representative CCP NA, EVE Online Contact Us at http://support.eveonline.com/pages/petitions/createpetition.aspx |
|
| |
|
| Pages: 1 :: [one page] |