527 Posted Topics
Re: [QUOTE=nouryn;653055]I Used to be a c++ programmer and now i'm starting to learn java all by my self so i need a help in how to get starting begging with compiler and IDE tools and the basic diffrants between c++ and java Thanks[/QUOTE] Since you used to be a programmer, … | |
Re: I'm going to assume you have done tests in the following way-- [code=c++] #include <cstdlib> #include <iostream> using namespace std; struct Sort{ public: int arraySize; void swap(int&, int&); int partition(int[], int, int); void quickSort(int[], int, int); bool test(); }; void Sort::swap(int &value1, int &value2) { int temp = value1; value1 … | |
Re: > Write the definition of a method reverse , whose parameter is an array of integers. The method reverses the elements of the array. The method does not return a value > > So far I got: public void reverse(int[] backward) { for(int i = (backward.length -1); i >=0;i--){ } … | |
Re: Get rid of the paranthesis around set-- [code=c++] bool Sort::test() { Sort set; bool answer = false; [/code] | |
Re: Ok I saw some weird lines in your code. It looks like you declared inner classes within the scope of your methods. I'm really not sure how Java handles that. Typically any type that is declared within a method is destroyed unless it is a valid pointer. Then again I … | |
Re: There are far, [I]far[/I] more errors to that code than just the illegal start of expression warning. Fist of all I can see a nested method declaration/definition which is illegal Secondly your System statements aren't capitalized in some areas. I can see many other errors such as the System.out.println printing … | |
Re: [QUOTE=TeCNoYoTTa;652137]thanks .....:D:D but i also want to know when to use it and what is it's uses[/QUOTE] A function that returns a valid reference can be treated as a lvalue. [code=c++] int& sumz(int x,int y) { int *sum = new int; *sum = x + y; return *sum; } [/code] … | |
Re: You don't need to keep posting different topics about this. Since I'm not very helpful, I will for the last time point out the error then quit replying. [code=java] import java.util.*; public class IntNode { public int item; //element in list public IntNode next; //next node in list public IntNode … | |
Re: [QUOTE=JConnor135;651927]For this code to delete an element from a linked list how do I get the head to point to the first element in the list(which is 0)? [ICODE]public class IntNode1 { public int item; public IntNode1 next; public IntNode1 head; //////Constructor/////// public IntNode1(int item1, IntNode1 next1) { next=next1; item=item1; … | |
Re: I think what you mean is you want a wrapper class-- [code=c++] #include <iostream> #include <cstdlib> class SubFoo{ }; class Foo{ private: SubFoo *sub; public: Foo(SubFoo &obj) : sub(&obj){} Foo(SubFoo *obj) : sub(obj){} }; int main(){ Foo foo = new SubFoo; SubFoo sb; Foo foo2 = sb; return 0; } … | |
Re: [code=java] import java.util.*; import java.text.NumberFormat; public class Election2 { public static void main(String[] args) { Scanner kb = new Scanner(System.in); // declaring/defining a Scanner object and giving it a handle to the standard input stream String[] names = new String [5]; // empty string array declaration/definition, stores 5 Strings short[] … | |
Re: Before I give you another suggestion for simply fixing one error, I'm curious to know what kind of Linked List you want to make? It looks like you want to make a doubly linked list, but I could be wrong. It also seems that you may, instead, be making a … | |
Re: Beware of stale-data declarations! Here's the code revised, but I'm not sure if it will do exactly what you want. [code=java] import java.util.*; public class IntNode { public int item; public IntNode next; public IntNode head; IntNode prev = null; IntNode curr = head; //////Constructor/////// public IntNode(int item1, IntNode next1) … | |
How in the hell do you divide by 7 using nothing but-- ~, ^, >>, <<, &, | -- In a set algorithm. I'm stumped. I've tried mapping out different numbers dividing by each other... it didn't work. I would map out a number subtracting from the other to see … | |
Re: I think this is what you meant-- [code=c++] // Code Shark #include <iostream> #include <windows.h> #include <string> using namespace std; int main() { srand(time(NULL)); unsigned int digit = 0, digit2 = 0, correct = 0, wrong = 0; string answer; do { system("Cls"); digit = rand() % 9 + 1; … | |
Re: [QUOTE=sftwr21;650065]Hello everyone, I'm learning programming for the first time and my first book i bought from the book store is the new Deitel C++ 6th edition. After reading the first several chapters I got so overwhelm with the authors verbose; I went out and bought C++Primer. One thing I noticed … | |
Re: An I/O Exception is being thrown. You may find it useful to look up the Socket class in the java.net API [url]http://java.sun.com/javase/6/docs/api/java/net/Socket.html[/url] Here's a quote from the Socket constructor you're using-- [icode] Socket public Socket(String host, int port) throws UnknownHostException, IOException Creates a stream socket and connects it to the … | |
Re: [QUOTE=VernonDozier;648495]I imagine you want this line: [code] quarter = .25 number % quarter [/code] to be something like: [code] quarter = number / 0.25; [/code] If you have $1.78, you'll have 7 quarters, which is 1.78/0.25 (integer division truncates to 7). I don't think you want to % operator at … | |
Re: [QUOTE=herms14;648813]it also doesn't work. I've tried it but my outputs are some strange symbols nothing else..[/QUOTE] Ok this is just theory but-- Why not read every value (separated by spaces) as a string then sstream them into ints and store that sstream'd value into an indice of the array? | |
Re: You forgot to return when the writeLine function reaches zero. Because of that it doesn't act as a sentinel, and writeLine just keeps writing String values to the screen. Also, it's a good idea to put your code in blocks during a condition. Here's the modified code. Msg me if … | |
Re: [QUOTE=Ancient Dragon;649237]I have no idea what you want. >>can help me? Can we help you do what?[/QUOTE] I think he wants our support...? | |
Re: [QUOTE=ivailosp;639857][code=cpp] int x = 21; x = (x << 2) + (x << 1) + x; //multiply number by 7 cout << x; [/code][/QUOTE] Can you not shift 0, or did you feel it was redundant? | |
Re: It could be that string is defined in namespace std, which you forgot to declare that you are using. Either that or declare-- [ICODE] using std::string [/icode] or-- [icode] std::string var; [/icode] | |
Re: Wow sending data is that simplified in C++? My god, that is incredibly easy. | |
Re: 1) Please use Code Tags. 2) After just glancing through your project I noticed a huge error-- [code=java] Movie[0] = new Movie("I'm", 01, $1.00); Movie[1] = new Movie("In", 02, $2.00); Movie[3] = new Movie("Hell" 03, $3.00); // skipped Movie[2] Movie[4] = new Movie("Help!" 04, $4.00); // null pointer exception [/code] … | |
Re: [QUOTE=sambafriends;647806]Hi, thanks for ur replay I need to explain classes in english and C++ I want the difference between procedural programming language and opps languages with beautiful example regards,[/QUOTE] Oh so you mean mid-level commands vs high level commands? [I]"Procedural programming A programming methodology involving a linear, 'shopping list' approach … | |
I still get here the same way I do every day - through a bookmark I have with this particular link: [url]http://www.daniweb.com/forums/post618391.html#post618391[/url] and I realize how poorly I first wrote less than 2 months ago when I first joined and started C++ I've learned a lot, and am still learning. … | |
Re: [QUOTE=bloody_ninja;644046]Hi, I just started research and playing around with Java a week ago. My uncle's company gave me all the necessary software and everything, and now I am trying to learn as much as I can in the fastest possible time. Browsing through the first page, I realized that I … | |
Re: [QUOTE=VernonDozier;647777]Is this you, or someone in the same class? [url]http://answerboard.cramster.com/computer-science-topic-5-287440-0.aspx[/url] Regardless, please check out the answer given and post back with any follow-up questions.[/QUOTE] Wow, talk about tracked down! | |
Re: [QUOTE=williamhemswort;647368]Yes, windows tend to do that for alot of types, and sometimes theres no need for them, for example in one of the header files I found these: [CODE=CPP] #define CONST const typedef int INT; typedef float FLOAT; [/CODE] and hunderds more.. ;)[/QUOTE] Hmm I wonder... [code=c++] typedef void VOID … | |
Re: [QUOTE=omarelmasry;646856]I am making a c++ program and i need a function that does the following: IF u have an n (e.g: 4) digit number (IN THE FORM OF AN ARRAY) , each digit can take the vlaue from 0 to m (e.g: 5) and can exist more than once in … | |
Re: [QUOTE=CoolGamer48;647417]But wait, doesn't this work? [CODE=C++] int x; cin >> x; [/CODE] x is an int, not a reference to one. Is it different when you're dealing with function return types and just the data type of a variable?[/QUOTE] x is technically a placeholder for an int, therefore it can … | |
Is it possible to send something like, a Frame or Applet to a target computer? If not, how would I set it up so that two users from two different computers could interact with the same JFrame or JApplet? Edit: No I'm not asking for code, just general advice* | |
Re: If you're serious about making a game, you should really write out (or type out) what is that you want to do in your game. Make a list with boxes next to each item (or "thing to do" ) then start programming around your list. Find out whats easy to … | |
Forgive me for my lack of Java-lingo. In fact I'd like to find a book someday that will teach me all of the definitions of words that are mentioned for Java classes and objects, as well as processes, etc. If the title isn't at all clear, what I mean is … | |
I'd like an opinion, although it will probably be biased since I'm asking the members of the C++ forum and not the members of Java. I'd also like to apologize in advance if this topic has been done before, but I don't like bumping old topics from years ago. I … | |
Re: [QUOTE=Waseemn;646736]Thank you for your reply. I did read up on the ArrayList, and unfortunately I am not allowed to use them due to the insistence of the instructor about not using anything not covered in class. I know where he is coming from, but again that limits us to what … | |
| |
Re: This is a little of topic, but what courses will you be specializing in? 5 days seems fairly quick unless it's a specialization training course then I'd understand. Sorry for the random question, just curious. Disregard it if you want to keep that kind of information confidential. -Alex | |
Re: [QUOTE=TheWhite;645782]Because I have other code in my program that checks if(frame2 == null)... and having the X dispose() does not make it = null.. It just hides it there until you bring it up again... Is there a way to ask if a frame has been disposed because I could … | |
I am wondering how one would append additional memory to the end of a pointer that already has memory allocated? For example, if I do something like this... [code=c++] int *intPtr = new int[5]; // pointer can be assigned 5 values of type int // Now I want to add … | |
I'm getting ridiculous results in my program! Seconds work fine Decaseconds (1/10 of a second) work ok Centiseconds seem a bit off Milliseconds are completely off... Here's the code-- [code=java] import javax.swing.*; import java.awt.event.*; public class Clock{ private Timer t; private long startTime = 0, finishTime = 0; private boolean … | |
Re: [QUOTE=d4n0wnz;644717]Hi, I am taking a course that is Java based over the summer and the prerequisite class which I took a year ago was in c++ and has recently been switched over to java. So now the class expects me to have a good background in java but there is … | |
Re: This actually reminded me of the project I'm working on. You could do something like this, where you use an Engageable interface to allow implementing classes to attack one another. Here's the interface (in Java) [code=java] //import CharacterData.*; //import DisplayPackage.*; /** * interface Engageable * Provides a means of Engagement … | |
Re: [QUOTE=ssharish2005;644823] ... 1. [B]Java compiles the code to bytecode, not binary[/B] 2. It requires a JVM 3. It’s slow 4. Lack of pointers. 5. Needs huge amount of memory. And remember ATMEL AVR are RISC based processor. Does JVM support RISC architecture??? From my research it seems that ARM can … | |
Re: [QUOTE=Ezzaral;644685]You can use [URL="http://java.sun.com/javase/6/docs/api/java/lang/String.html#valueOf(long)"]String.valueOf(long)[/URL] to get a long into a string.[/QUOTE] If the instructor doesn't even allow the String API then... [code=java] public class Number_Manip{ public static void main(String[] args){ System.out.println(Number_Manip.numberToString(new Integer(8))); } public static String numberToString(Number num){ return "" + num; } } [/code] | |
Re: You might need to make a minor edit-- [code=java] public class Grades { public static void main(String[]args) { Instructor grades = new Instructor(); grades.congratulateStudent( 'A' ); // enter a char as parameter here, 'A', 'B', 'C' etc char grade = args[0].charAt(0); } } [/code] | |
Re: Rofl S.o.p 50 times... [code=java] public class LazyBass{ public static void main(String[] args) throws Exception{ System.out.println("Now you see me..."); Thread.sleep(2500); clrscr(); System.out.println("Now you don't!"); } public static void clrscr(){ for(int i = 0; i < 56; i++) System.out.println(); } } [/code] Edit: Looks like 56 is the lucky number! | |
Re: Correct me if I'm wrong but do you mean Varargs? Example... [code=java] public class VarArgTest{ public static void main(String[] args){ String values1[] = {"Mom", "Dad", "Sis"}; VarArgTest.myVarArgMethod(values1); VarArgTest.myVarArgMethod(" ", " "); VarArgTest.myVarArgMethod("Yo", "This", "Rocks", "My", "Socks"); } public static void myVarArgMethod(String... strings){ for(String element : strings) System.out.println(element); } } [/code] |
The End.