• We've upgraded our forums. Please post any issues/requests in this thread.

Help a beginner with Java

Joined
Jul 26, 2010
Messages
1,655 (0.61/day)
Likes
729
Location
Philly
System Name Primary Rig
Processor Phenom II X4 B50 @ 3.7GHz
Motherboard Biostar TA790GX 128M
Cooling Sunbeam CR-CCTF 120mm , 6x120mm, MOS-C1
Memory 2x2GB Kingston HyperX 1066 @ 800 4-4-4-12
Video Card(s) Sapphire HD 5830 800/1000 @ 885/1225
Storage 320GB, 400GB, 500GB, 1.5TB
Display(s) Hannspree HF259
Case CM 690
Power Supply OCZ 850W
Benchmark Scores 3Dmark06: 18545/5219 CPU Mark 7.0: 3911.2 Cinebench R10: 11826/3359 x264 HD 2.0: 75.6/23.9
#26
That isn't how you declare a while loop.

That's a for loop declaration.

It should be:
Code:
[B]for[/B] (int i = 0; i < 25; i++){
It's a very common mistake, don't feel bad about it.
 
Last edited:
Joined
Apr 26, 2008
Messages
1,106 (0.31/day)
Likes
178
Location
london
System Name Staggered
Processor Intel i5 6600k (XSPC Rasa)
Motherboard Gigabyte Z170 Gaming K3
Cooling RX360 (3*Scythe GT1850) + RX240 (2*Scythe GT1850) + Laing D5 Vario (with EK X-Top V2)
Memory 2*8gb Team Group Dark @3000Mhz 16-16-16-36 1.25v
Video Card(s) Inno3D GTX 1070 HerculeZ
Storage 256gb Samsung 830 + 2*1tB Samsung F3 + 2*2tB Samsung F4EG
Display(s) Flatron W3000H 2560*1600
Case Cooler Master ATCS 840 + 1*120 GT1850 (exhaust) + 1*230 Spectre Pro + Lamptron FC2 (fan controller)
Power Supply Enermax Revolution 85+ 1250W
Software Windows 10 Pro 64bit
#27
:banghead: I feel like crying in the corner now.

Edit: but a stupid one none the less. Seeing as I've used it correctly several times before.
 
Joined
Sep 15, 2004
Messages
1,561 (0.32/day)
Likes
207
Location
Poland,Slask
System Name HAL
Processor Core i5 2500K
Motherboard Asus P8P67 Pro Rev3.1
Cooling stock
Memory 2x4GB Kingston 1600Mhz Blu
Video Card(s) Asus 560Ti DirectCuII TOP
Storage Kingston 120 3K SSD,WD Black WD1502FAEX
Display(s) LG 1440x900
Case Chieftec Mesh Midi
Audio Device(s) onboard
Power Supply Corsair TX750V2
Software w8
#28
Maybe use FOR instead of WHILE :)
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#29
What would be a logical step up from the archery game? Preferably something that doesn't require much imagination (so no text adventure).
Good job on the game :toast:

The next logical step would be to make the game more complex.
For instance, instead of just having the target be X distance away, give it a left and right position so that the player has to enter the angle to turn also (Power=10, Angle=25, 30° to the left).
If the player misses, have the target advance and moves left or right toward him some random amount before the next shot. If the target reaches the player, the player "dies".
See if the player gets the target or the target gets the player (call it a zombie instead of a "target" :D )

Then ... add multiple zombies attacking.

Also, I saw your comment about methods returning void (or nothing).
This means it returns no value to whatever called it. You will also get an error if you try to get a return value from a void method.
Code:
void MyMethod()
{
    // Do something, but return nothing.
}

int test = MyMethod() <-- Error
However, if a method returns a value, you do not have to use it if you do not need what it returns.
 
Last edited:
Joined
Apr 26, 2008
Messages
1,106 (0.31/day)
Likes
178
Location
london
System Name Staggered
Processor Intel i5 6600k (XSPC Rasa)
Motherboard Gigabyte Z170 Gaming K3
Cooling RX360 (3*Scythe GT1850) + RX240 (2*Scythe GT1850) + Laing D5 Vario (with EK X-Top V2)
Memory 2*8gb Team Group Dark @3000Mhz 16-16-16-36 1.25v
Video Card(s) Inno3D GTX 1070 HerculeZ
Storage 256gb Samsung 830 + 2*1tB Samsung F3 + 2*2tB Samsung F4EG
Display(s) Flatron W3000H 2560*1600
Case Cooler Master ATCS 840 + 1*120 GT1850 (exhaust) + 1*230 Spectre Pro + Lamptron FC2 (fan controller)
Power Supply Enermax Revolution 85+ 1250W
Software Windows 10 Pro 64bit
#30
So a void method is like a bully?
"What's yours is mine and what's mine is also mine.", said the void method to the other methods.
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#31
Another thing to keep in mind, as I stated above, is that when you look at code just because a method call does not use it's return value, does not mean it does not return anything.

For instance, the Show method of the MessageBox class in C# returns a value of type DialogResult. If you don't care what that value is, you can call the method and just let it pitch the result or use it if you need it.
Code:
MessageBox.Show("Text for messgae box"); // Don't need result

or

DialogResult MyResult = MessageBox.Show("Text for message box"); // Save result for later
A void method isn't a bully, it's just so broke it can't afford to give anything back :D


Also, Java is not dead. It's used by a lot of people for it's cross-platform capabilities.
for instance, Minecraft is written in Java.
 
Last edited:
Joined
Nov 10, 2008
Messages
1,897 (0.57/day)
Likes
676
System Name Star Citizen Enabler
Processor Intel Core i7 4770K @ 4.2GHz
Motherboard MSI Z87-GD65
Cooling Triple 120 rad WC with EK-Supreme LTX CSQ waterblock
Memory 16GB Corsair Vengeance Pro 1866MHz C9
Video Card(s) MSI Gaming 6G GTX 980Ti
Storage Corsair Force 3 120GB, Kingstone V300 240GB, Seagate Barracuda 1.5tb, Samsung Spinpoint F1 1tb
Display(s) Oculus Rift DK2 + 24" 1920x1200 HP LP2475w(H-IPS panel)
Case Corsair Obsidian 800D
Audio Device(s) Asus Xonar D2X (pci-e) with optical into logitech z-5500 speakers
Power Supply Corsair HX850i
Software Windows 7 Professional 64-bit [full retail]
#32
That's why a large number of corporations have programs written in Java (some of these programs make billions each year in revenue)? Java is hardly dead, and it isn't going to be going away for a looong time.

As for what to develop next Kreij is right - it is much better to improve on and add to an existing program if you want to try more complex things, at least until you can't think of any more ways to add to it.
 
Last edited:
Joined
Apr 26, 2008
Messages
1,106 (0.31/day)
Likes
178
Location
london
System Name Staggered
Processor Intel i5 6600k (XSPC Rasa)
Motherboard Gigabyte Z170 Gaming K3
Cooling RX360 (3*Scythe GT1850) + RX240 (2*Scythe GT1850) + Laing D5 Vario (with EK X-Top V2)
Memory 2*8gb Team Group Dark @3000Mhz 16-16-16-36 1.25v
Video Card(s) Inno3D GTX 1070 HerculeZ
Storage 256gb Samsung 830 + 2*1tB Samsung F3 + 2*2tB Samsung F4EG
Display(s) Flatron W3000H 2560*1600
Case Cooler Master ATCS 840 + 1*120 GT1850 (exhaust) + 1*230 Spectre Pro + Lamptron FC2 (fan controller)
Power Supply Enermax Revolution 85+ 1250W
Software Windows 10 Pro 64bit
#33
Currently I'm going through the different kind of data structures (array, bitset etc.). After that I'm going to learn basic swing and remake "Fate/stay night" with place-holders for all the audio, text and images. That ought to help in getting used to the syntax.
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#34
When learning the different data structures, take the time to learn not only how they work but where they are a "best fit".

If you need a data structure to hold a bunch of strings you could use an array, but depending upon what you are doing (like maybe adding and remove them) a List of string may be more appropriate because it will execute faster and is inherently dynamic in size.

Human Error said:
As for what to develop next Kreij is right - it is much better to improve on and add to an existing program if you want to try more complex things, at least until you can't think of any more ways to add to it.
You mean after writing your first "Hello World" program you should not jump right into making a 3D shooter? :laugh:
 
Joined
Jul 26, 2010
Messages
1,655 (0.61/day)
Likes
729
Location
Philly
System Name Primary Rig
Processor Phenom II X4 B50 @ 3.7GHz
Motherboard Biostar TA790GX 128M
Cooling Sunbeam CR-CCTF 120mm , 6x120mm, MOS-C1
Memory 2x2GB Kingston HyperX 1066 @ 800 4-4-4-12
Video Card(s) Sapphire HD 5830 800/1000 @ 885/1225
Storage 320GB, 400GB, 500GB, 1.5TB
Display(s) Hannspree HF259
Case CM 690
Power Supply OCZ 850W
Benchmark Scores 3Dmark06: 18545/5219 CPU Mark 7.0: 3911.2 Cinebench R10: 11826/3359 x264 HD 2.0: 75.6/23.9
#35
No offense good sir, but I've seen your posts: you do not know that much about programming.
So a void method is like a bully?
"What's yours is mine and what's mine is also mine.", said the void method to the other methods.
It should be noted that void methods can still modify variables, whether globals, class members or certain types of passed objects (similar to python). This gets confusing so check this out:
http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html

Java doesn't support void type variables (AFAIK) but other languages do. For instance I wanted a function to retrieve private variables from a class instance in C++. The traditional way to do this is with a template, which is a type of generic specific to C++. (Java [J2SE 5.0+] also supports generics.) I intend to create a generic but for now I'm prototyping the behavior using void:
PHP:
//Exposes private variable values
//note: might want to change this to BOOL in case name detection fails
//warning: this is not production quality code, it's for debugging only
void ProfileControl::request(void* var, LPCTSTR name) {
	if (_tcscmp(name,_T("settings"))==0){
		unsigned char* tSettings=(unsigned char*)var;
		*tSettings=settings;
	}
	else if (_tcscmp(name,_T("profilesSaved"))==0) {
		vector<wstring>* tProfilesSaved=(vector<wstring>*)var;
		*tProfilesSaved=profilesSaved;
	}
	else if (_tcscmp(name,_T("szDir"))==0) {
		TCHAR* tszDir=(TCHAR*)var;
		_tcscpy(tszDir, szDir);
	}
	else if (_tcscmp(name,_T("find"))==0) {
		wstring* tProfile=(wstring*)var;
		wstring profile;
		if (findprofile(*tProfile, &profile)) {
			*tProfile = profile;
		} else {
			*tProfile = _T("");
		}
	}
	return;
}
What that function does is allow you to pass in a variable of several different types, then request a variable by name and retrieve the desired value from the object instance. It would be invoked like this:
PHP:
TCHAR szDir[MAX_PATH];
tProfileControl->request(szDir,_T("szDir"));
It also uses loads of pointers which Java doesn't support . . .

NOTE: I'm using php tags for syntax highlighting, the code is written in C++.
When learning the different data structures, take the time to learn not only how they work but where they are a "best fit".
Not only that, but if razaron learns how to build his own data structures he can fit data structures to code rather than fit code to data structures. I'm pretty sure that sounds more confusing than I want it to be.
 
Last edited:

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#36
Not only that, but if razaron learns how to build his own data structures he can fit data structures to code rather than fit code to data structures. I'm pretty sure that sounds more confusing than I want it to be.
We may want to give raz a little time to let the basics sink in before we give him an aneurysm trying to figure out delegates, generics, llambda expressions, etc. :D
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#37
Keep it on topic. He asked for help with Java, not for personal opinions on the merits of any particular programming language. Posts removed.
 
Joined
Dec 2, 2009
Messages
3,257 (1.11/day)
Likes
315
System Name Mercury KM-81
Processor Phenom II x4 B50
Motherboard ASUS M4A89GTD PRO
Cooling Cooler Master Hyper TX3
Memory 6GB Ram (4GBx1 Corsair 2GBx1 Nanya)
Video Card(s) PowerColor AX6770 V2.0
Storage 2TB WD Black, 1TB Hitachi, 500 GB WD Blue
Display(s) Philips 247E-LPH 24" 1920x1080
Case Mercury
Audio Device(s) Integrated Realtek
Power Supply Corsair 750TX
Software Windows 7 64-bit
Benchmark Scores Maybe it is time to benchmark :D
#38
Ok, sorry for the other post, but anyway i don't know why none suggested any videos
http://www.youtube.com/watch?v=Hl-zzrqQoSE
Thenewboston is well known for teaching
If i was you i would learn all the videos than come here again after learning that much
@streetfighter 2
I have not seen a program like the one in my signature.... yet
 
Last edited:
Joined
Apr 26, 2008
Messages
1,106 (0.31/day)
Likes
178
Location
london
System Name Staggered
Processor Intel i5 6600k (XSPC Rasa)
Motherboard Gigabyte Z170 Gaming K3
Cooling RX360 (3*Scythe GT1850) + RX240 (2*Scythe GT1850) + Laing D5 Vario (with EK X-Top V2)
Memory 2*8gb Team Group Dark @3000Mhz 16-16-16-36 1.25v
Video Card(s) Inno3D GTX 1070 HerculeZ
Storage 256gb Samsung 830 + 2*1tB Samsung F3 + 2*2tB Samsung F4EG
Display(s) Flatron W3000H 2560*1600
Case Cooler Master ATCS 840 + 1*120 GT1850 (exhaust) + 1*230 Spectre Pro + Lamptron FC2 (fan controller)
Power Supply Enermax Revolution 85+ 1250W
Software Windows 10 Pro 64bit
#39
[figured it out]
 
Last edited:
Joined
Apr 26, 2008
Messages
1,106 (0.31/day)
Likes
178
Location
london
System Name Staggered
Processor Intel i5 6600k (XSPC Rasa)
Motherboard Gigabyte Z170 Gaming K3
Cooling RX360 (3*Scythe GT1850) + RX240 (2*Scythe GT1850) + Laing D5 Vario (with EK X-Top V2)
Memory 2*8gb Team Group Dark @3000Mhz 16-16-16-36 1.25v
Video Card(s) Inno3D GTX 1070 HerculeZ
Storage 256gb Samsung 830 + 2*1tB Samsung F3 + 2*2tB Samsung F4EG
Display(s) Flatron W3000H 2560*1600
Case Cooler Master ATCS 840 + 1*120 GT1850 (exhaust) + 1*230 Spectre Pro + Lamptron FC2 (fan controller)
Power Supply Enermax Revolution 85+ 1250W
Software Windows 10 Pro 64bit
#40
This results in a stackoverflow error.
If I remove " && halffact1==0.75 && halffact2==0.75 && halffact3==0.75" from the "checkGrid()" method then it results in an array full of zeros.
What am I doing wrong?
Code:
import java.util.*;

public class test{
	static Random rand = new Random();
	
	public static void main(String args[]){
		print(secondaryGrid());
	}
	
	
	//prints MD array
	public static void print(int[][] x){
		for(int j=0;j<3;j++){
			for(int i=0;i<3;i++){
				System.out.print(x[i][j]+" ");
			}
			System.out.println();
		}
	}
	
	
	//makes the permutation of numbers 1-3
	public static int[] getPerm(){
		int[] temp = {1,2,3};
		int[] perm = new int[3];
		int sum = 0;
		
		do{
			for(int i=0;i<3;i++){
				int r = rand.nextInt(3-i);
				perm[i] = temp[r];
				temp[r] = temp[2-i];
				sum += perm[i];
			}
		}while(sum != 6);
		return perm;
	}
	
	
	//sets up the rows in a primary grid with previously made permutations
	public static int[][] primaryGrid(){
		int[][] primaryGrid = new int[3][3];
		int[] row1 = getPerm();
		int[] row2 = getPerm();
		int[] row3 = getPerm();
		
		for(int i=0;i<3;i++){
			primaryGrid[i][0] = row1[i];
			primaryGrid[i][1] = row2[i];
			primaryGrid[i][2] = row3[i];
		}
		return primaryGrid;
	}
	
	
	//returns a secondary grid based of the primary grid, if checkGrid is true.
	public static int[][] secondaryGrid(){
		int[][] primaryGrid = primaryGrid();
		int[][] secondaryGrid = new int[3][3];
		
		if(checkGrid(primaryGrid)==true)
			secondaryGrid = primaryGrid;
		else
			secondaryGrid();
		
		return secondaryGrid;
	}
	
	
	//sets and returns the boolean value, checkGrid, based on the columns of a grid
	public static boolean checkGrid(int[][] x){
		int sum1 = 0;
		int sum2 = 0;
		int sum3 = 0;
		int fact1 = 1;
		int fact2 = 1;
		int fact3 = 1;
		double halffact1 = 1;
		double halffact2 = 1;
		double halffact3 = 1;
		
		boolean checkGrid = false;
		
		for(int i=0;i<3;i++){
			//sums
			sum1 += x[0][i];
			sum2 += x[1][i];
			sum3 += x[2][i];
			//factorial
			fact1 *= x[0][i];
			fact2 *= x[1][i];
			fact3 *= x[2][i];
			//halved factorials
			halffact1 *= (double)(x[0][i]/2);
			halffact2 *= (double)(x[1][i]/2);
			halffact3 *= (double)(x[2][i]/2);
		}
		
		if(sum1==6 && sum2==6 && sum3==6 && fact1==6 && fact2==6 && fact3==6 && halffact1==0.75 && halffact2==0.75 && halffact3==0.75)
			checkGrid = true;
		else
			checkGrid = false;
		
		return checkGrid;
	}
	
}
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#41
I'm not sure but it looks like the checkGrid method is returning itself (which would cause a stack overflow because you are not specifying that it return the local boolean variable by the same name (this.checkGrid).
 
Joined
Apr 26, 2008
Messages
1,106 (0.31/day)
Likes
178
Location
london
System Name Staggered
Processor Intel i5 6600k (XSPC Rasa)
Motherboard Gigabyte Z170 Gaming K3
Cooling RX360 (3*Scythe GT1850) + RX240 (2*Scythe GT1850) + Laing D5 Vario (with EK X-Top V2)
Memory 2*8gb Team Group Dark @3000Mhz 16-16-16-36 1.25v
Video Card(s) Inno3D GTX 1070 HerculeZ
Storage 256gb Samsung 830 + 2*1tB Samsung F3 + 2*2tB Samsung F4EG
Display(s) Flatron W3000H 2560*1600
Case Cooler Master ATCS 840 + 1*120 GT1850 (exhaust) + 1*230 Spectre Pro + Lamptron FC2 (fan controller)
Power Supply Enermax Revolution 85+ 1250W
Software Windows 10 Pro 64bit
#42
To call a method in Java you must have "()" at the end of the name even if there are no parameters.
Today is not your day, lol.

EDIT: The method checkGrid() returns a boolean named checkGrid, the method primaryGrid() returns an array named primaryGrid and the method secondaryGrid() returns an array called secondaryGrid. I realize this is confusing. That's just how I like it...
 
Last edited:

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#43
You are right. Today has not been my best day. lol
Oh well, it's not the first time.

I know you need to include the parenthesis when calling a method, but I was thinking that when you return checkGrid (without the parenthesis) it may be returning a pointer to the method instead of the value of the local checkGrid variable.

I probably just need some sleep so I can once again seperate different programming language syntax in real time. :roll:

Code:
private static protected const internal void **string MyMethod (string *$lolwut)
{
   10 : return ***this.MyMethod->&MyMethod (&(LPTRSTR)(@"Just kill me now"));
   goto: 10;
}
 
Last edited:
Joined
Apr 26, 2008
Messages
1,106 (0.31/day)
Likes
178
Location
london
System Name Staggered
Processor Intel i5 6600k (XSPC Rasa)
Motherboard Gigabyte Z170 Gaming K3
Cooling RX360 (3*Scythe GT1850) + RX240 (2*Scythe GT1850) + Laing D5 Vario (with EK X-Top V2)
Memory 2*8gb Team Group Dark @3000Mhz 16-16-16-36 1.25v
Video Card(s) Inno3D GTX 1070 HerculeZ
Storage 256gb Samsung 830 + 2*1tB Samsung F3 + 2*2tB Samsung F4EG
Display(s) Flatron W3000H 2560*1600
Case Cooler Master ATCS 840 + 1*120 GT1850 (exhaust) + 1*230 Spectre Pro + Lamptron FC2 (fan controller)
Power Supply Enermax Revolution 85+ 1250W
Software Windows 10 Pro 64bit
#44
I took the recursion out of the secondaryGrid() method and moved the double casts (in the checkGrid() method) into the brackets. It now works perfectly.
 
Joined
Apr 26, 2008
Messages
1,106 (0.31/day)
Likes
178
Location
london
System Name Staggered
Processor Intel i5 6600k (XSPC Rasa)
Motherboard Gigabyte Z170 Gaming K3
Cooling RX360 (3*Scythe GT1850) + RX240 (2*Scythe GT1850) + Laing D5 Vario (with EK X-Top V2)
Memory 2*8gb Team Group Dark @3000Mhz 16-16-16-36 1.25v
Video Card(s) Inno3D GTX 1070 HerculeZ
Storage 256gb Samsung 830 + 2*1tB Samsung F3 + 2*2tB Samsung F4EG
Display(s) Flatron W3000H 2560*1600
Case Cooler Master ATCS 840 + 1*120 GT1850 (exhaust) + 1*230 Spectre Pro + Lamptron FC2 (fan controller)
Power Supply Enermax Revolution 85+ 1250W
Software Windows 10 Pro 64bit
#45
I have a really weird problem.
This works,
PHP:
long time = getTime();
double theta = (360*time)/1000;
long x = (long)(100 * Math.cos(Math.toRadians(theta)));
long y = (long)(100 * Math.sin(Math.toRadians(theta)));
but this doesn't,
PHP:
long time = getTime()%1000;
double theta = 360*((time)/1000);
long x = (long)(100 * Math.cos(Math.toRadians(theta)));
long y = (long)(100 * Math.sin(Math.toRadians(theta)));
This code is supposed to give the x,y co-ords of a dot thus animating it. getTime() returns a long value of time in milliseconds.
The second piece of code is mathematically sound but doesn't work.
 
Last edited:

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#46
Define "doesn't work".
 
Joined
Apr 26, 2008
Messages
1,106 (0.31/day)
Likes
178
Location
london
System Name Staggered
Processor Intel i5 6600k (XSPC Rasa)
Motherboard Gigabyte Z170 Gaming K3
Cooling RX360 (3*Scythe GT1850) + RX240 (2*Scythe GT1850) + Laing D5 Vario (with EK X-Top V2)
Memory 2*8gb Team Group Dark @3000Mhz 16-16-16-36 1.25v
Video Card(s) Inno3D GTX 1070 HerculeZ
Storage 256gb Samsung 830 + 2*1tB Samsung F3 + 2*2tB Samsung F4EG
Display(s) Flatron W3000H 2560*1600
Case Cooler Master ATCS 840 + 1*120 GT1850 (exhaust) + 1*230 Spectre Pro + Lamptron FC2 (fan controller)
Power Supply Enermax Revolution 85+ 1250W
Software Windows 10 Pro 64bit
#47
One animates. The other just has a static image.
I fiddled a bit more and figured out something even more weird. If for the second piece of code I make theta equal (360*time)/1000, it animates.
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#48
The two code blocks you posted are not mathematically equivelant.
I guess still an not sure how to respond.
 
Joined
Apr 26, 2008
Messages
1,106 (0.31/day)
Likes
178
Location
london
System Name Staggered
Processor Intel i5 6600k (XSPC Rasa)
Motherboard Gigabyte Z170 Gaming K3
Cooling RX360 (3*Scythe GT1850) + RX240 (2*Scythe GT1850) + Laing D5 Vario (with EK X-Top V2)
Memory 2*8gb Team Group Dark @3000Mhz 16-16-16-36 1.25v
Video Card(s) Inno3D GTX 1070 HerculeZ
Storage 256gb Samsung 830 + 2*1tB Samsung F3 + 2*2tB Samsung F4EG
Display(s) Flatron W3000H 2560*1600
Case Cooler Master ATCS 840 + 1*120 GT1850 (exhaust) + 1*230 Spectre Pro + Lamptron FC2 (fan controller)
Power Supply Enermax Revolution 85+ 1250W
Software Windows 10 Pro 64bit
#49
The cosine and sine make them mathematically equivalent. The theta values are different but the cos(theta) and sin(theta) values are the same. Check it on a calculator.
Also, 360 * (time/1000) == (360*time)/1000. Think of them as fractions.
 
Last edited:
Joined
Dec 2, 2009
Messages
3,257 (1.11/day)
Likes
315
System Name Mercury KM-81
Processor Phenom II x4 B50
Motherboard ASUS M4A89GTD PRO
Cooling Cooler Master Hyper TX3
Memory 6GB Ram (4GBx1 Corsair 2GBx1 Nanya)
Video Card(s) PowerColor AX6770 V2.0
Storage 2TB WD Black, 1TB Hitachi, 500 GB WD Blue
Display(s) Philips 247E-LPH 24" 1920x1080
Case Mercury
Audio Device(s) Integrated Realtek
Power Supply Corsair 750TX
Software Windows 7 64-bit
Benchmark Scores Maybe it is time to benchmark :D
#50
I think it is not a mathematical problem here.
It is java which takes the time as another thing and an int as another.
Probably you cannot divide time.
Not that i know java though.

Also, this 360 * (time/1000) == (360*time)/360 is not equal