Hi all, I am just getting into the world of OOP and I'm not totally sure in what situations it's better to use objects and when it's simpler to just revert to arrays. For example, I am currently re-writing a bit of scientific code written in C that simulates the evolution of the solar system. The crux of the simulation lies in the particles in the original disc of material, which has certain properties such as mass. In the original C code this is simply implemented as different arrays for each characteristic of the particles, with each row of each …

Member Avatar
Member Avatar
+0 forum 18

Hello, regarding OOP I have Java background, and I usually think in java when I code OOP in python (which sometimes is actually a bad thing). [CODE=python]#!/usr/bin/python class Card(): SUIT = { 'C':'Clubs', 'D':'Diamonds', 'H':'Hearts', 'S':'Spades' } VALUES = { '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, \ '10':10, 'J':12, 'Q':13, 'K':14, 'A':15 } def __init__(self,ctupl): """ New card instance. 'ctupl' = (str,str): denoting (SUIT,VALUES) """ if type(ctupl) != tuple: raise TypeError("Need (str,str) tuple.") self.suit = ctupl[0] self.value = ctupl[1] def __init__(self,suit,value): if type(suit) != str or type(value) != str: raise TypeError("Need str,str as parameters.") self.suit = suit self.value …

Member Avatar
Member Avatar
+0 forum 4

Hey guys, I have a problem. I have a connections_lib.php file this will handle all of my db connections, this works AMAZINGLY (power of OOP). Unfortunately some of my other classes require connection to the databse therfore they must use these methods (is that the right word for OOP I'm new, or function whatever). How would I go about doing this, I get the following error with this code: [b]Fatal error:[/b] Call to a member function start() on a non-object in [b]C:\xampp\htdocs\project5\includes\members_lib.php[/b] on line [b]14[/b] The scripts are ordered in the order they are shown below. [b]File: connections_lib.php[/b] [code]<?php class …

Member Avatar
Member Avatar
+0 forum 6

I am desperately need help converting my code into an OOP format. [B][I]Here is my code:[/I][/B] [CODE] #include <iostream> #include <string> #include <cstring> using namespace std; const int strLength = 141; char strArray[strLength]; char answer; bool quit; int charAmount; string line; void vowelCount(string); void consonantCount(string); void consonantCount(string line) { int consonants; consonants = 0; for(int i=0;i<charAmount;i++) { if (strArray[i] != '1') { if (strArray[i] != '2') { if (strArray[i] != '3') { if (strArray[i] != '4') { if (strArray[i] != '5') { if (strArray[i] != '6') { if (strArray[i] != '7') { if (strArray[i] != '8') { if (strArray[i] != …

Member Avatar
Member Avatar
+0 forum 1

Would anyone be able to provide pointers / comments on this object-oriented PHP program? You can take a look at it on [URL=http://github.com/codejoust/PHPContactForm/]http://github.com/codejoust/PHPContactForm/[/URL] It's still a work in progress.

Member Avatar
+0 forum 0

The End.