Member Avatar

this program calculates all the prime numbers between two input numbers num1 and num2. first an array is created and num1,num1+1,......num2 are stored in that array and then all elenemts of array are scanned and if they are divisible by any odd number except itself or by 2 then 0 is stored in tht array element....... later all non zero elements are printed....... is my algorithm wrong or program wrong? [CODE] #include<iostream> #include<conio.h> using namespace std; class prime { int num1,num2,length; public: void nextprime(); prime(int nm, int mn){num1=nm; num2=mn;} }; int main() { int m,n; int choice; cout<<"how many times …

Member Avatar
0
4
Member Avatar

I'm searching for a good tutorial about object oriented analysis and design but can't find any short and clear tutorial which will has: 1. Explanation of oo concepts (very short) 2. CODE EXAMPLE (eg. if someone describe aggregation I wanna see how I can use this in my class) There is a lot of tutorials but they are all without code example except this one: [url]http://www.cs.gordon.edu/courses/cs211/ATMExample/index.html[/url] This is great tutorial but on harder example. It would be perfect if there is a similar tutorial on easier example. The last thing, please if possible give me the link for C++ or …

Member Avatar
0
8
Member Avatar

Hey everyone. I've been contemplating something lately and I haven't been able to come to a conclusion, so I thought I'd see what you all thought about it. When checking for null (nevermind that we should try to not make something null in the first place), would it be better to check that something is not null and continue, or to check if it is null and exit the method early? ie: A) [CODE] void method() { if(object != null) { dostuff; } } [/CODE] or: 2) [CODE] void method() { if(object == null) return; dostuff; } [/CODE] I tend …

Member Avatar
0
5
Member Avatar

I'm new to PHP OOP. The project need a site class and the below is my code (): [CODE]class Sites { private $siteName; private $location; private $postcode; function __construct($name, $loc, $pc) { $this->siteName = $name; $this->location= $loc; $this->postcode = $pc; //use "insert SQL" to store new added site info to DB $insertSQL = "INSERT INTO table_name (siteName, location, postcode) VALUES ($siteName, $location, $postcode)"; } function getSiteName($SiteID){ selectSiteName = "SELECT siteName FROM site WHERE siteID = $SiteID"; return $this->siteName; } function getSiteLocation($SiteID){ selectLocation = "SELECT location FROM site WHERE siteID = $SiteID"; return $this->location; } function getPostCode($SiteID){ selectPostcode = "SELECT postcode …

Member Avatar
0
7
Member Avatar

I'm trying to understand utilizing classes and their methods. I made a simple program to exit or print 'Will continue' given a word. however I keep getting a TypeError for self and through reading my books and searching online I'm still not quite sure why. the code is: [CODE]class OffSwitch(object): def __init__(self): self.keycheck='off' def turnOff(self,key): if key==self.keycheck: SystemExit else: print('will continue') switchword=input('Enter a word: ') OffSwitch.turnOff(switchword)[/CODE] and getting the error[CODE]Traceback (most recent call last): File "E:/classpractice", line 14, in <module> OffSwitch.turnOff(switchword) TypeError: turnOff() takes exactly 2 arguments (1 given)[/CODE]

Member Avatar
0
12
Member Avatar

[B]Beginner's guide to C++0x: Avoiding Memory Problems by Design of Ownership[/B] If you ever read any resources on C++ programming or object-oriented programming, you must have heard some rethorics like "inheritance is for the [I]is a[/I] relation, composition is for the [I]has a[/I] relation". Is that all? Is that the end of the story? What is the underlying motivation for this dichotomy? What if my case fits neither category? The point of this tutorial is to answer those questions and show how to translate the answers into real C++0x code. This tutorial is really about thinking about the relationships between …

Member Avatar
8
103
Member Avatar

have planned to write my own light weight MVC for PHP, that will be used as base for my sites I develop. I have no problem with PHP, OOP, et al. I have trouble on how to actually load Models In controllers and use them amd loading Controller values into Views. In short, I don't know how M-V-C interact behind the scenes. Any tutorial (concentrating on that) or any contribution is welcomed! Thanks!

Member Avatar
0
8
Member Avatar

[CODE]#include<iostream.h> #include<conio.h> class student{ //student class // student class attributes // Access specifier is by default private int ID; char * name; public:// public acccess specifier // student class functions/ operations void login(); bool Select(); void read(); }; // end of student class // ******************************************************************** // ******************************************************************** // ******************************************************************** class topic{ // topic class //topic class attributes // Access specifier is by default private int ID; char * title; public: // public access specifier // topic class functions/ operations void add(); void remove(); bool select(); void search(); void View(); void print(); void download(); };// end of topic class // ******************************************************************** …

Member Avatar
-4
3
Member Avatar

Hey friends ..I need a help.. I want to know that to learn oop concept is RUBY language good...? we have to choose between RUBY and OCAML. Please can anyone explain a bit..Thanks in advance

Member Avatar
0
5
Member Avatar

Hi there, Please can someone help me! I have recently been learning oop PHP. I have created a class for my database, which basically makes my life easier when doing queries. I have created a "where" method which basically when used will append to the select statement. For example: //class I have created $query = new MySqlDb; //this is the where statement $query->DbWhere("LULevel='10' && LUId='200'"); //db select statement $res = $query->DbSelect("*", "login","ORDER BY LUFName ASC"); Now the above code works absolutely fine but the value for the where method is: "LULevel='10' && LUId='200'". I want to neaten it up so …

Member Avatar
0
3
Member Avatar

I am currently working on a banking system that has 3 classes. customer, savingsAccount and transaction. I have created the 3 classes but am having problems with the saveAcnt object in the customer class. I need to link it with the savingsAccount class. Any help would be appreciated. Also I should note that each class is located in its own header file and they are all #include'd in the main cpp program. [CODE=c] /* savingsAccount.h */ #include <iostream> using namespace std; class savingsAccount { public: void createAccnt(int, double, double); void addDeposit(double); void subWithdraw(double); void addInterest(); private: int accntNo; double balance; …

Member Avatar
0
5
Member Avatar

This is an answer to a question in C++ area. [url]http://www.daniweb.com/software-development/cpp/threads/355232[/url] It should be ready to be modified to code in C++, C#, or Java, because VB.Net is fully OOP. Even though it can be used for vectors, you may still want to modify it to a Vector Class.

Member Avatar
0
4
Member Avatar

I haven't done any sort of development for a while, but what i'm looking for is to see a simple example of an ntier application using linq. Showing BLL, DAL with roles and membership. I'm also keen on getting better with my OOP and would like to find a site that has console type application exercises so I can practice. Thanking you in advance for your help.....and I hope I haven't asked for too much.

Member Avatar
0
7
Member Avatar

im totally new in object oriented progrmng in C++ course, i have to create a table in which i have to answer in yes /no that for example if class can be public so the answer is Y and if class can not be public then answer will be N. im having a problem. i have done this so far. please help me out in the following table: its in attachment: [ATTACH]19821[/ATTACH]

Member Avatar
0
5
Member Avatar

I have recently started learning Object oriented programming and design. I had made a small program using the procedural design to move a block after selecting it in XNA. I then tried to make the same program with an Object centered Design, but I am not able to make it work. The block is to change color when clicked but isn't in the OO version and I am not able to figure out why :(( . I have uploaded both the solutions, I want the OOP version to works as the procedural one is working. i.e. Change color when clicked …

Member Avatar
0
3
Member Avatar

Can anyone please explain what is 'public' and 'private' in oop and specifically in java? I am a bit confused.

Member Avatar
0
8
Member Avatar

hello people i am new to oop , well , i am good in the normal php but i started oop today and now i am getting too many errors . check the class_lib.php bellow , it has my classes and mainly the database connectors .: [CODE] <?php class db { var $do; function __construct() { mysql_connect("localhost","root")or die("cant connect to MySQL server : ".mysql_error()); } function select($select) { mysql_select_db($select) or die("cant select the db : ".$select); } function query($data) { $q = mysql_query($data); if($q) { echo ""; } else { echo "Error : ".mysql_error(); } } function close() { mysql_close(); …

Member Avatar
0
3
Member Avatar

This is a request for some 'best practices' comments from experienced OOP practitioners. I have been in IT from the days of punched cards and have had considerable experience with legacy languages like 370 ASM, SAS, and REXX. For fun, I've taken a college class in C++ and am now working on a program for my personal use. I am building a program that will let me create, maintain, and search a database of articles from woodworking magazines and books I've gathered over the years. When I want to start a new project, I want to search this database for …

Member Avatar
0
4
Member Avatar

Im into the last stages of my C++ class and am having trouble with a project that has been assigned. Here is the problem and thanks in advance for whoever helps out! Declare an object of type bucket 1). Use the SetGallonSize() method to set the bucket size to 5.0 gallons 2). Use the FillBucket() method to fill the bucket to 3.2 gallons of water 3). Use the GetWeight() method to output the weight of the 3.2 gallons of water Here is the header file that was provided [CODE] // bucket.h #ifndef _BUCKET_H #define _BUCKET_H const double WEIGHT_OF_WATER = 8.3; …

Member Avatar
0
4
Member Avatar

Hey y'all, I was just curious about which idiom you prefer or use very often.. and why? Please vote on the poll! I understand that there are a lot of choices but you can vote for multiples, but try to pick only the ones you think are the best, or most useful, or most elegant to use, i.e., the ones you value most and/or recommend the most. - Resource Allocation Is Initialization - Non-copyable - Factory Functions - PImpl (Cheshire Cat) - Singleton - Lazy construction or evaluation - Type Traits - Smart Pointers - Curiously Recurring Template Pattern - …

Member Avatar
0
4
Member Avatar

plz mention me the errors i dont understand what i do.. [CODE]#include<fstream> #include<iostream> #include<string> #include<ctype.h> #define _TABSIZE 4 using namespace std; int tabsize = _TABSIZE; class token { public: token() : _what(code) {} public: enum type {code, comment, pp, keyword}; string _str; type _what; friend istream& operator>>(istream&, token&); friend ostream& operator<<(ostream&, const token&); }; bool iskeyword(const string& s) { static const char* keywords[] = { "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", "class", "compl", "const", "const_cast", "continue", "default", "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", "float", "for", "friend", "goto", "if", "inline", "int", "long", …

Member Avatar
0
5
Member Avatar

Hi * I have spent the last 18 hrs or so trying to get the wright sql code or think of an alternative but I just can't get my head around it. If any one can help me it would be awsome. What I am trying to acheive is getting the correct id to echo out in the row variable. [CODE]<?php echo $row['id']; ?>[/CODE] but it has to based on the mysql table row user_id which is based on the session username so it works off the users table id. I have two tables one is users the other is …

Member Avatar
0
12
Member Avatar

Hi, I have a question regarding Object Orientated Programming as it is baffling me. Lets say I have a form called register. It is made up of Username, Password and Emai. Now when the user clicks submit the form will be handled by the class register but how does the methods know what the values are ? [CODE] <form name="register" action="register.php"> Username<input type="text" name="Username" /> Password<input type="text" name="Password" /> Email<input type="text" name="Email" /> </form> [/CODE] Now I would have a method within a class like below: [CODE] public function checkLogin($Username, $Password) { // carry out form processing } [/CODE] How …

Member Avatar
0
4
Member Avatar

I need some help to theme my website a test project to learn cakephp 1.3.4. I have created files for these like default.ctp for website default layout. and home.ctp for home page layout, I try Google for help but there I found nothing a good tutorial for a beginner to help me understand how to use any theme or layout for cakephp website. Can some give a reference link to any material that helps me to understand what exactly I have had to do with cakephp design techniques?

Member Avatar
0
2
Member Avatar

Hi there; I hope I post this message in true place.My question is about modules in oop. In Code complete, author Mr Steve McConnell mentioned "module" in page 89. [QUOTE] Semantic coupling The most insidious kind of coupling occurs when one module makes use not of some syntactic element of another module but of some semantic knowledge of another module's inner workings. Here are some examples: * Module1 passes a control flag to Module2 that tells Module2 what to do. This approach requires Module1 to make assumptions about the internal workings of Module2, namely what Module2 is going to do …

Member Avatar
0
3
Member Avatar

Hi everyone My intention is to enable NTLM authentification when using the native PHP SOAP client, Most of the code is copied from an php.net manual example and it is said to be working. I'm trying to override the __doRequest function in the SoapClient class and let it use cURL. But I can't get the overriding part to work. __doRequest is never called, What am I doing wrong? Any suggestions ? [CODE]class ExtSoapClient extends SoapClient { private $proxy_login; private $proxy_password; ... public function __construct($wsdl, $options = array()) { $this->proxy_login = $options['proxy_login']; $this->proxy_password = $options['proxy_password']; $this->proxy_host = $options['proxy_host']; $this->proxy_port = $options['proxy_port']; …

0
1
Member Avatar

I currently have 12 files I've designed for database connect. I have 1 interface, 1 main class & 11 sub classes. File List: iDatabase.php Database.php mySQL_connect.php mySQL_close.php mySQL_error.php mySQL_errno.php mySQL_escape.php mySQL_query.php mySQL_array.php mySQL_row.php mySQL_assoc.php mySQL_num.php mySQL_id.php While I've gotten as far as creating all the class code & the interface, I'm stuck at how to connect them & utilise them in a separate file. If anyone could give me on insight that would be wonderful. Thanks for you time

Member Avatar
0
2
Member Avatar

I'm having a hard time understanding where is the problem... I have a class which is responsible connecting to DB and passing queries. (basically Data Access Layer) and it looks like this: [code=php] class DB { private $connection; public function __construct(){ $this->connection = mysql_connect('localhost', 'user', 'pass'); mysql_select_db( 'dbname', $this->connection ); } public function exec_query( $query ) { mysql_query($query, $this->connection ); } } [/code] when I instantiate this class, everything is great... no errors but when I call exec_query method, it prints the error: [B]supplied argument is not a valid MySQL-Link resource[/B] and does not execute the query

Member Avatar
0
7
Member Avatar

Can someone please explain to me why I cannot move variables from object to object. I've been getting no sleep and burning myself out learning java and it is driving me crazy here is the example. [CODE]import static java.lang.System.out; class ONE { public static void main(String[] args) { TWO addition = new TWO(); double test = 123.321; double test2 = 456.654; double test3 = 888.888; double sum = addition.getadded(test, test2); out.println(sum); } }[/CODE] and [CODE]import static java.lang.System.out; class TWO { double getadded(test, test2){ return test + test2; } }[/CODE] and error [CODE]--------------------Configuration: <Default>-------------------- C:\Users\Empire\Desktop\java\testing\TWO.java:4: <identifier> expected double getadded(test, test2){ ^ …

Member Avatar
0
4
Member Avatar

Hi everyone. We were given a homework to code a hash table. The objects and their members were given by our professor and we were only supposed to implement the functions (Add, Remove, Contains and Print), so I shouldn't change the objects. I should also do a copy constructor and a assignment operator (but that's another story i don't think I'll have any problems with that after I solve my current problem). The code compiles just fine but at first I got a segmentation fault on the line 158: HashTable[HashCode(key)].Add(key). In debug mode HashCode(key) = 5 which is OK (5%10 …

Member Avatar
0
7

The End.