Urgent help

Questions about programming languages and debugging
Post Reply
User avatar
l0ngb1t
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 598
Joined: 15 Apr 2009, 16:00
15
Contact:

Urgent help

Post by l0ngb1t »

am working on a project and am getting this error that is killing me
because ATM it's 4:32 am over here and i have to mail to the prof after 7 hours and do a presentation about it on monday
so any help please i fixed all the errors
but the rest 12 error are all related :( helppppppp
my head has blown up
this is the code

Code: Select all

http://code.suck-oold.com/40643
There is an UNEQUAL amount of good and bad in most things, the trick is to work out the ratio and act accordingly. "The Jester"

User avatar
Lundis
Distorter of Reality
Distorter of Reality
Posts: 543
Joined: 22 Aug 2008, 16:00
15
Location: Deadlock of Awesome
Contact:

Post by Lundis »

Your constructor returns void and is misspelled.

Code: Select all

public void allitems(String name){
	this.name = name;
}
There should not be a semicolon after for and you're suddenly using "movies" instead of "videos". Also, array.length always returns the length of the array, in this case 100, causing your app to crash.

Code: Select all

public void list(String s){
	if(s == "book")
		for(int x = 0 ; x<books.length ; x++);
			books[x].printDetails();
	if(s == "music")
		for(int x = 0 ; x<music.length ; x++);
			music[x].printDetails();
	if(s == "video")
		for(int x = 0 ; x<movies.length ; x++);
			movies[x].printDetails();
	if(s == "software")
		for(int x = 0 ; x<softwares.length ; x++);
			softwares[x].printDetails();
}
The first error's still there though...

A couple of other notes, please state the error when you're asking us to figure it out, it's kind of annoying to compile it ourself when we could've figured the mistakes out by seeing the compiler output.

Your indentation is often completely random and you're mixing whitespace and tabs. It's almost as if different persons wrote the code, one used tabs and the other spaces.

The Java class naming convention is camel-case, which means your classes should be named this way:

Code: Select all

class Application { ... }
class AllItems { ... }
class Product { ... }
...
Also, your member variables are all public, which is the opposite to the java programming practises. Keep the members private and write get/set functions (or whatever the situation requires).

An array is not a good data structure for what you're doing, in fact as you seem to have realized at some point, it will crash when you add more than 100 products of one type. To fix that, I suggest using one of these structures instead: http://java.sun.com/j2se/1.4.2/docs/api ... yList.html, http://java.sun.com/j2se/1.4.2/docs/api ... ector.html .

User avatar
l0ngb1t
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 598
Joined: 15 Apr 2009, 16:00
15
Contact:

Post by l0ngb1t »

ok did some modification but still having an error help :(

Code: Select all

http://code.suck-oold.com/40644
There is an UNEQUAL amount of good and bad in most things, the trick is to work out the ratio and act accordingly. "The Jester"

User avatar
l0ngb1t
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 598
Joined: 15 Apr 2009, 16:00
15
Contact:

Post by l0ngb1t »

SOLVED

thanks lundis
i guess coding at 4 am is not good at all :P
There is an UNEQUAL amount of good and bad in most things, the trick is to work out the ratio and act accordingly. "The Jester"

Post Reply