Programming :: How To Modify ArrayList From Outside Of Class?
Mar 10, 2010
Okay so I'm working on a program here as I'm learning java,I have an array that is initialized with 5 objects that are hard coded. I have made a GUI that takes the input needed and creates an object with those values.I need to add that object to the ArrayList that I have previously made.Okay, so I have three classes, guiclass.java, main.java and gladiator.java Objects are made and defined in "gladiator".Main contains my public static void main section, launches my gui, creates my five hard coded objects, creates my ArrayList and adds my five hard coded objects to the ArrayList.Now, I need to add the object that I generated in the guiSection [action Listener]to the ArrayList that I created in my main class's public static void main string... section. Problem is my arraylist "cannot be resolved" from guiclass.
View 13 Replies
ADVERTISEMENT
Feb 12, 2011
im trying to build a simple program for my C programming class, this is the source code
#include <stdio.h>
int main()
{
int length, width, length, height, area, perimeter;
perimeter = width + length + height;
area = width * length + heigth;
[Code]...
i dont see any error (you might)but every time i run it it runs but after it asks me to input for the width i do it but it doesn't take me to the length, it just stays blank until i input another value in the same place for the width, it asks me for 4 inputs in total i don;t know why, and after i run it different times it gives me different values for the perimeter and are. how can I fix this?
View 5 Replies
View Related
Mar 12, 2010
I have a problem with compiling vdrift-2009-06-15 using scons. As the source that i obtained only supports scons i cannot use make. the error that i get when i try to compile it in GNOME Terminal is: scons: Reading SConscript files ... scons: warning: The Options class is deprecated; use the Variables class instead.
File "/home/mohit/Download/vdrift-2009-06-15/SConstruct", line 9, in <module>
scons: warning: The BoolOption() function is deprecated; use the BoolVariable() function instead.
File "/home/mohit/Download/vdrift-2009-06-15/SConstruct", line 13, in <module>
Checking for C++ header file asio.hpp... (cached) yes
Checking for C++ header file boost/bind.hpp... (cached) yes
Checking for C++ header file GL/gl.h... (cached) yes
Checking for C++ header file GL/glu.h... (cached) yes
Checking for C++ header file SDL/SDL.h... (cached) yes
[Code]........
View 4 Replies
View Related
May 18, 2010
I'm struggling with the issue of passing a vector of a class to itself, here's what state its in now... (tried many variations, but without direction).
Code:
#include <iostream>
#include <string>
[code]...
View 2 Replies
View Related
Apr 9, 2010
I am trying to make a periodic boundary condition type function, using an existing class given to me in lecture notes, but am having some trouble! Effectively, I am trying to make an array such that, for a point in any row of a 2D matrix ("Matrix(i,j)"), the command "next_i[i]" will return "(i+1)%L", where L is the number of data points in the row. This will enable me to select a point to the right of any point in the matrix: "Matrix(next[i],j)"
[Code]....
View 1 Replies
View Related
Apr 8, 2011
Is is possible to use a class inside a struct? I keep getting segmentation fault with this code:
Code:
struct my_struct {
unsigned count;
std::string msg;
[code]....
View 3 Replies
View Related
Mar 15, 2011
My new guy has created several functioning webpages on his machine with TOMCAT 6 with Sun JDK, yet our machines use TOMCAT 5.5 with Open JDK, which his webpages don't show. Do you have any idea how to make them work? The error showing in a browser:
Code:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception org.apache.jasper.JasperException: Unable to compile class for JSP:
[Code]...
View 2 Replies
View Related
May 10, 2011
I've had to do some code in java, a language I'm very much unfamiliarly with so please excuse my incorrect use of terms. The basic outline of my problem is I create a class object as a local within a swing button function it works fine. If I create it as a global ( with I think I need to do ) within main, then prototype it with the other swing objects at the bottom of the file when it is called it causes a host of problems. I think the easiest way is to show it.
View 2 Replies
View Related
Sep 18, 2010
I am looking to write a function to return an MD5 hash in Java but I don't want to us the MessageDigest class as I am using the J2ME framework which doesn't include it.
View 3 Replies
View Related
Sep 30, 2010
How can I handle the situation below so that the "Fatal Error" message is not shown. It would be ideal if I could supply a default class to be used. I'd prefer to not use: ini_set() to supress the errors but actually be able to "handle" the error.
Code:
<?php
class MyClass
[code]....
View 2 Replies
View Related
Feb 24, 2009
I have a application in C++, and now I have two class. MyDialog is the class that main function launch. In MyDialog class there are four elements and when I click over theese elements, there is a MousePressEvent that launch other class, Touchpad class. So, in some moments, I have loaded two class. My question is, how can pass a value from Touchpad class to MyDialog class, when I close (destroy) Touchpad class. In a few words, is it possible to communicate values between class?
View 5 Replies
View Related
Sep 3, 2010
i need to implement a Set class(like in stl) using a vector.Here is my code that doesnt work corectly:
Code:
#include <iostream>
#include <vector>
template<class T>
class Set
{
[Code]....
View 2 Replies
View Related
Oct 19, 2010
How can I implement c_str() for a string class?
View 2 Replies
View Related
Mar 23, 2010
Is it not possible to declare a vector inside a C++ class ? Have a look at the following code:
Code:
#include <stdio.h>
#include <iostream>
#include <malloc.h> // malloc
#include <strings.h> // bzero
[code]....
View 2 Replies
View Related
May 9, 2011
This is a really specific question, but maybe someone can help. I'm debugging someone else's code, and they call a UDPWriter and specify an IP address and port, and I'm trying to make sure this multicast traffic goes over a certain port. How can I determine which port the UDP defaults to and change it?
It's confusing to me because I'm not familiar with all the layers the OS sends traffic through before it goes through the interface. Is there maybe some simpler way to tell the OS to send multicast traffic over both interfaces?
View 2 Replies
View Related
May 23, 2010
i'm a bit stuck playing with the following class setup for glut. The actual issue is with the function pointers.Basically the following code is the opengl redbook cube example slightly modified.
View 2 Replies
View Related
Apr 27, 2011
I'm writing a binary search tree class to insert records and I'm stuck on the following error:
Code:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
Here is the code for my class:
[Code]...
I really don't know how to approach this, I thought that everything was working fine but I have no idea what is wrong. Also, for clarification, main() is in a different .cpp file that #includes "tree.h"
View 13 Replies
View Related
Jan 5, 2011
I have a JApplet class I have copied to both a windows and a linux server. When I open up a webpage with the applet in it in my browser from both servers (http://server1/....) I can only get it to work from the Windows server. The Java console on my PC pops up complaining it cannot find the class file on the Linux server. Has anyone experienced anything like this before and how have you solved the problem?
View 1 Replies
View Related
Mar 11, 2011
I'm trying to teach myself python (from Learn Python the hardway e-book) but am struggling to grasp the concepts of Classes etc. Part of exercise 43 is to rewrite the game / create a new game with classes for each room etc. So I'll show you my code so far and explain at the bottom my problem
Code:
#ex43a.py
from sys import exit
[code]....
View 2 Replies
View Related
May 12, 2011
I found out how to save an object using Serializable in JAVA, the standard however how can I set up my MainVariableList to have a function/method saveobject so it saves the object within it's own class, the below code compiles, however when I run it reports an error on startup but works, basically what do I use for the red line, how do I tell it what object is passed to the class?
View 1 Replies
View Related
Jun 27, 2010
how to overload the subscript operator ([]) for a list class?
Code:
template <typename T>
class list
{
public:
struct node
[Code]...
View 1 Replies
View Related
Sep 7, 2010
I have some c++ code and want to generate class diagrams using some tool which would scan the c++ code and generate diagrams. Is there any such open source tool to be used on linux machine?
View 1 Replies
View Related
Mar 9, 2010
Here's what I'm trying to do: I'm attempting to create a Worker program which is to be called in a Coordinator program. The worker program needs to add two numbers from the argv and return the sum of those numbers. Basically my problem is some sort of syntax and I'm fairly new to this scripting stuff. Here's what I have:
#!/bin/bash
# Worker class for the program Coordinator
int worker(int argc, char *argv[] {
int sum = 0;
sum = atoi(argv[1]) + atoi(argv[2]);
printf("I am child with PID %d", getpid());
printf("sum=%d
", sum);
fprintf(atoi (argv[3]), sum, 4);
exit(sum); }
Here's the errors:
~$./worker 2 4
./worker: line 4: syntax error near unexpected token `('
./worker: line 4: `int worker(int argc, char *argv[]'
View 5 Replies
View Related
May 18, 2010
This is a bit of revision for the OU course M257
Code: Select all import java.util.*;
public class FindDupes {
public static void main(String[] args) {
Set<String> orig = new HashSet<String>();
Set<String> dupe = new HashSet<String>();
for(String a: args)
if(!orig.add(a))
dupe.add(a);
orig.removeAll(dupe);
System.out.println("words " + orig);
System.out.println("dudes " + dupe);
}
}
for some reason it will compile but not run on debian lenny complains it can't find the main class but it compiles and runs without problem on Fedora 12.
View 6 Replies
View Related
Sep 14, 2010
I have a problem. This class is a base class for a basic enum handler:
Code:
#define ENUMOBJECT_BEGIN_ELEMENTS enum Element {
#define ENUMOBJECT_END_ELEMENTS ElementCount, DefaultElement, NoElement };
[code]...
View 8 Replies
View Related
Mar 30, 2011
I'm venturing into the world of OpenGL, but in the process of writing my graphics library I ran into a problem... My code is:
Code:
#include <stdio.h>
#include <stdlib.h>
[code]...
View 5 Replies
View Related
Feb 24, 2011
please i try to compile the below code on ubuntu with g++ but i was getting an error message
fig03_05.cpp:10: error: new types may not be defined in a return type
fig03_05.cpp:10: note: (perhaps a semicolon is missing after the definition of �GradeBook�)
fig03_05.cpp:32: error: two or more data types in declaration of �main�
[code]...
View 7 Replies
View Related
Oct 6, 2009
i have trouble to define a static member in a template, and i search from google, but didn't find any similar case, my case is a little complex, i paste the code below.code in xxx.h
Code:
template <class T> class FreeListManager
{
[code]...
View 6 Replies
View Related
Mar 28, 2011
I had some trouble doing this but finally figured it out. Here is a general solution:
Code:
#include <iostream>
using namespace std;
[code]....
View 1 Replies
View Related
May 5, 2011
I am getting a linker error for a simple program to represent a singleton class.
Find below the program which I have written:
View 3 Replies
View Related