Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm not sure what you are using for a textbook in your course, but you might want to take a look at this free online book. It's an older edition, but most everything still applies.
Thinking in Java
http://www.smart2help.com/e-books/tij-3rd-edition/TIJ3.htm

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You are using the constructor in CdwArtist to set the artist when the object is created. Since you no longer have an empty constructor, CdwArtist(), you can't create one like that. You would need the following instead

CdwArtist artist = [B]new[/B] CdwArtist(input.nextLine());
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your change will work fine, as long as you don't have any decimals in the subtotal, otherwise you'll clear them. If you need to accommodate the decimal you can add it to the filter.

The substring would work for any number of digits - it just returns everything past the "$" character(you had a space in there as well, hence the starting value of 2 rather than 1) - but use whichever method you like as the only important part is getting them into the array as numbers :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I have another meeting to go to now, I do not fully understand the use of (string in) and artist=in just yet, and I will still have to code my Inventory class, but a little reading this evening should set me up for that.
Thanks again guys, you always help get me back in the right direction.

The (String in) part is just the parameter declaration of the method signature. You are defining a String parameter named "in". You could call it whatever you like, it's just a variable for the parameter that you will use inside your method. Which leads to the "artist=in" part. You are setting "artist" equal to the parameter that was passed, "in". You could have called it "artistName" instead if you preferred. Then you would set "artist = artistName".

Make sense? It's merely a variable name for that parameter of type String.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Advertising?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, times will differ. Enough to care about? That depends on what you are doing with them.
The first will incur array access costs in accessing the deeper sub-arrays, but working with subsets of information may be faster.
The second is linear, so element access will be faster but you can't process entire subsets without picking out individual elements to work with (depending upon what you intend to do with them).
If these aren't very large arrays it will probably make little difference. If you are working in long loops on them then times could vary greatly, depending upon the operations performed.
Testing is your best friend, write clear concise code that meets your needs first and then optimize it if performance problems warrant it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

One point for jwenting as there is no paint interface and one point for Ezzaral as there is Paint interface which can be found here.

hehe Ok, points for all.
The posted question is extremely vague though, so I doubt much help is forthcoming.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It just declares a variable of type (class) Artist. You get "Cannot find symbol" because you do not have a class Artist. Your constructor should be

public CdwArtist(String in) {
   artist=in;
 }

since you have declared a String property "artist".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

well what u did was the black list thing
and what i did is white one
it may look the same
but it is not!

Yes, I got it turned around, which I mentioned previously :)

Anyway, it does not matter. I posted to support that what you posted should work for him, he just needs to tune the pattern to include his acceptable characters :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, what TheGathering said. Perhaps if you called your new class CdExtended it would make a little more sense to you. CdExtended has all of the info of Compactdisk plus artist info. To use that extra info, you need to use the CdExtended object in your code instead of the base level class of Compactdisk.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Actually Java does have a Paint interface in java.awt for defining color patterns, but I have never had a need to implement it in any Graphics2D work I've done to date. You would only need it if you were defining a customer color-type class.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
preg_replace( "/[^a-zA-Z0-9_]/", "", $stringToFilter );

i guess this could work for your case
replacing everything that is not char. or digit with whitespace

That was what I was getting at, but I see I dropped the "^" when I retyped my earlier expression. It should work fine as a single character mask.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

i just installed Wamp 5.1.7.2, and guess what... nothing changed... i'm going nuts now...

Don't be insulted if this is an obvious question, but did you start Wampserver? And is the file saved as ".php"?

Edit: Your code as posted runs just fine here on my machine.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You are calling array_sum with a single value:

echo (array_sum($subtotal[$k]));

instead of the array itself. Use

echo (array_sum($subtotal));

to get the sum of that array.

That alone won't work for your file as you posted it though. You have the column names as the first row and you have dollar signs in from of the subtotal values, so an echo of the array contents yields:

subtotal  $30  $120

which sums to 0. Try the following instead:

$item = file('order.txt');
        foreach($item as $key => $val){
            $data[$key] = explode(",", $val);
        }
        for($k = 1; $k < count($item); $k++){
            $subtotal[$k] = substr($data[$k][4],2);
        }
        foreach($subtotal as $val)
          echo $val.' ';
          
        echo 'Sum: '.(array_sum($subtotal));
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I do. I was unable to find another 'how-to' for this problem, so when I found the answer I decided to post it. I hope it was useful, but I understand better solutions may be out there. Please let me know if you know of one--I would surely benefit from it.

Well, you can use instanceof instead of having to drill down to the classname,

if (comp instanceof java.awt.Button){

but if you only add this listener to the buttons then that check is unnecessary - you already know it's a button.

Just two minor points there though. Your solution is just fine.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you are using Windows, have you tried Wampserver?
http://www.wampserver.com/en/

One simple install for Apache, PHP, and mySQL. Works immediately without having to screw around with the various config files.

(Linux has LAMP packages available I believe if you need those instead)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If the whitelist is entirely comprised of single characters, you can probably use

preg_replace( "[^#$%]", "", $stringToFilter );

to replace any occurrence of "#","$",or "%" with an empty string. Just put whatever characters you need to strip in there. If it's not a simple single character situation (i.e. you need to strip something like "<p>") then you'll have to go deeper into regex land to get there.

Actually, sorry, that pattern is bad, use this instead

preg_replace( "/[#$%]/", "", $stringToFilter );

(It was too late to edit the other post)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Oh! hehe I just re-read the SQL and can't believe I missed that before. Insert statements do not have WHERE clauses. Are you trying to insert a new record or update an old one? Update code would be

UPDATE members SET email='$email' WHERE username='$username' and password='$password'
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I suppose you could stuff all of the data into something like

$data[$category][$subcategory][$entry]

but I'm not sure if that will make it easier or more difficult for you to manage :)

The display part would be pretty easy at that point, since it only requires a series of nested for loop to generate output. Not knowing the database structure it's harder to say if you can push the data into the structure quite as easily from your queries.

Just a thought.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If the whitelist is entirely comprised of single characters, you can probably use

preg_replace( "[^#$%]", "", $stringToFilter );

to replace any occurrence of "#","$",or "%" with an empty string. Just put whatever characters you need to strip in there. If it's not a simple single character situation (i.e. you need to strip something like "<p>") then you'll have to go deeper into regex land to get there.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I think weber was suggesting something like

for ($i=0; $i<count($data); i++)
  $subtotal[$i] = $data[$i][4];
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Why is the name of your internal variable for storing the checkbox array important to what the user sees? I guess I'm missing that part.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Does the query work fine from a SQL tool, like phpMyAdmin or such? I've not seen table names surrounded with the "`" before, but that may be unrelated. Are there non-nullable fields that you are not including in your insert? If you don't want to try it out in a SQL tool you could try

$result=mysql_query($sql) or die("SQL Error".mysql_error());

to see what it is complaining about.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I tried out a few LCDs 2 years ago, when response times were still in the 15+ ns range and had backlighting issues. I just didn't like them for gaming so I returned them. Ended up sticking with the CRT. The current lines have much quicker response times (6-8 ns), but I haven't bothered to try them out again. I'm guessing they are much better now.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's funny because I have a long Visual Basic history but I found C# so much more elegant to type in a code editor, it was like a breath of fresh air. I find VB.NET soooo wordy, in fact I struggle to use it now.

I mean how can:

Dim x As Integer

Ever be better than:

int x;

?

And for me:

If(x = 0)

Is just wrong, = is an assignment operator.

Agreed. After using Java for years now, I can hardly stand to read VB syntax anymore. We still have to maintain some old Excel VBA templates here and none of us like having to get back into the VB code (VB6, not .NET).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Home - 19" Viewsonic CRT (LCD still weren't up to games very well when I bought it)

Work - 3 19" LCDs

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

"If trees could scream, would we be so cavalier about cutting them down?

We might, if they screamed all the time, for no good reason."

- Jack Handy

ChrisHunter commented: funny post +0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Started with BASIC on a Commodore Vic-20, programs were saved to a tape cassette :)

Later had BASIC and Pascal classes in HS and the engineering college was still requiring a course in Fortran (on the VAX, not PC, bleh.. ).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Post the entire piece of code and use the code tags.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I really think we should just get rid of anyone who is found in possesion of anything more the Pot. Think of th money our countries could save on medical bills care and the Doll on these people. Whats its cost for a bullet 10c? compare that to the millions if not billions being spent worldwide keeping these people alive to suck the system dry another day.

I suppose we should also shoot elderly people, those with severe injury that cannot work, those with severe mental retardation, the lazy, the extremely fat... hmm, who else can we off to save on medical care and social programs?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, your first post did not show any code to check for those entries and went straight to the mail() statement.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

westsiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiide loool people i don't know what you guys have against smoking peopl and i was lying about me being a smoker but 7/8 of my friends mixed of boys and girls are smokers and i don't mind i am a second hand smoker since i was 12 and i got nothing wrong with me so i think these doctors are bunch of liars

I think many would consider that a debatable statement. Your anecdotal evidence may be working against your argument.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I know, why don't we run these tech people, all they use is a handbook, we have a brain :D
Everyone on here could easily be a better 'tech guy' than the one's PC World have :)

Um, because we already have or at least aspire to have better jobs than fielding hundreds of phone calls from clueless people who have no idea how to operate their computer yet they expect you to magically make it work over the phone?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The scariest roller coaster I've been on is The Borg at Carowinds. You lay down instead of sitting or standing.

I would imagine these seven found it a bit scary as well:

(Saturday, March 18, 2007) - Seven Carowinds employees suffered minor injuries while test riding the BORG Assimilator roller coaster at Paramount's Carowinds theme park in Charlotte, North Carolina. According to park officials, the ride operator unlocked the pins that hold the seats in place as the train was leaving the station, causing the seats to shift position.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

you would be amazed the amount of people ho would do something like that

some builders killed themselves near us by running a petrol generator indoors

Sadly, no, I would not be amazed. I never underestimate the capacity of people to get themselves killed doing foolish things.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I don't see anywhere that your code checks to see if there is anything in the error array and display it if needed. It just goes on to attempt to send the mail and it also doesn't check the return value of the mail function. Make sure you are actually displaying any errors in your error message array and you may want to try to echo your mail parameters prior to sending, to make sure those look ok to you. Capture the return value from mail() and check that as well.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

... and not do something dumb like have an indoor bbq

In general, not doing something dumb figures greatly into longevity.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, on that note:
http://www.rideaccidents.com/

(scroll down to the News section)

Cheery reading!

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You could do the whole site in Flash I suppose :P
... which of course would be really slow and irritating...

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Does it have to be cigarette smoke, or would, say, secondhand fireplace smoke serve as well?

Oohhh, yeah, those filthy old fireplaces.. loitering about homes and smoking away with not a care in the world about the non-smokers! The nerve of those things!! :@

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Planned by bush and his cronies - not a snowball in hell's chance.

Allowed to happen through incompetence and inaction of one or more previous administrations - pretty likely.

Caused by US foreign policy which continues to honk off a large majority of the worlds population with it's "we're all right jack" attitude - certainly.
Essentially summed up as "give us cheap oil and fuck the rest of you".

Exploited by bush under the guise of "security" to introduce a whole raft of laws, and "justify" all sorts of illegal activities as a consequence of the event - absolutely certain, no questions asked (then, since or now).
When speaking out in opposition is labelled "un-patriotic", can the jack-booted thought police be far behind?

The last thing the planet needs is a god-soaked moron in charge of the only super-power, who thinks he might have a prophetic destiny. Especially since he's surrounded by brown-nosing sycophants who would blindly make it happen.

Your founding fathers must be spinning in their graves at the things which have happened in the last decade or so.
http://www.wisdomquotes.com/000974.html

I'm glad I visited the US a long time ago before all this stuff happened, because I doubt I would ever want to visit again whilst it treats all visitors as criminals.

Right on the head. Demagoguery for the lose. It's a shame more of our own citizens haven't seen this much sooner. Yet, people are coming around slowly. Bush's approval rating is at …

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, I was going to call it a day and just relax for the rest of the weekend, but Peter got me all fired up, so before I shut her down I decided to throw one more twist. Wouldn't it be clever to keep a running total of the values? I thought. I currently display the value of each cd depending on how many are in stock and its price.
How hard could it be to just sum that field. Apparently harder than I though. Here is what I came up with: Value being the name of the parameter already used, and cdCount being my counter.

public static float calculateTotal(Inventory completeValue[]);
            
                float totalValue = 0;
                for ( int cdCount = 0; cdCount < completeValue.length; cdCount++ )
                {
                totalValue += completeValue[cdCount].getValue();
                } // end for
                return totalValue;

I just inserted that at the bottom of my Compactdisk class, right after the brace that closes return(price * nstock);, but before the one that ends the class.
I get
Compactdisk.java:79: illegal start of type
for ( int cdCount = 0; cdCount < completeValue.length; cdCount++ )
^
Compactdisk.java:83: <identifier> expected
return totalValue;

I thought this would be simple, can anyone see what I am missing? It almost looks to me as if it does not like the method there at all.

See peter_budo's post on your method. You just didn't put your braces in correctly and you have a semi-colon at the end of the line you declare …

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Got it ... I think.
I put the Compactdisk class back in, and just modified it for the new array ... at least that is what I think I did.
It looks good, it runs well ( a few bugs to work out, but I think I have it)
Tell me what you think Ezzaral, I might have to put your name as a reference in this somewhere if I ever get it working! :o)
Just look at the name variable right now, that is all I have implimented at this point. Here is the main class.

Ok, I'll inline and comment a few things in your code below. It's very close, but inadvertently you have altered your loop to keep working on the same object over and over for several of the property sets. If you wish to use a simple variable to reference them, instead of cds[#], you will need to set the variable to point to the array entry you want to work with. If you are still confused by the cds[0].getName() style code, just remember that cds[] array contains all of your cd objects and by using cds[#] you can operate on the one you want exactly like you would any other variable that pointed to a cd (ie thisCompactdisk). Take a look at the parts I have changed in your code below.

import java.util.Scanner; //uses class Scanner

public class Inventory
{// begin class Inventory
    public static void main(String[] args)    
    {//begin …
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That depends on the operating system and the user permissions on that operating system...
On Windows it's indeed hard (but not imposssible) to remove an open file, on Linux it's quite possible.

Yes, that could be quite possible. All of our users for this app are on Windows, so no testing of the lock scheme has been done on Linux or Mac. In our case, it's not really a big concern since having multiple instances running will only cause them confusion, not critical application problems or a security risk.

It's good to know about the potential problems that might occur on they other OSs though, for future references. Thanks for the input :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

druggies are a drain on society. They're not productive (if you're always either high or low on something you can't hold a job), criminal (because they steal to fund their habbit), and tend to require more medical care than others.

Some druggies are a drain and not productive. I've known many people though who smoke marijuana and performed exceedingly well in professional careers, handled their finances responsibly, and led active lifestyles with no more health issues than what would be considered normal. In the same vein, I've seen alcoholics ruin their lives, jobs and families. Severe obesity also limits productivity, incurs high medical care needs and is a contributing factor in some of the top causes of death - Coca Cola and McDonalds are still legal and not subject to any more taxation than celery.

Destructive and irresponsible behavior is not limited to those who indulge in illegal substances. People will make their own choices and must live with those consequences for the good or bad.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Are you needing something like this?

$sql = "SELECT * FROM myTable";
  if ($rs = mysql_query($sql, $dbConn)){
      echo "<table>";
        for ($i=0; $i<mysql_num_fields($rs); $i++) {
            echo "<th>".mysql_field_name($rs,$i)."</th>";
          }
        while ($row = mysql_fetch_row($rs)) {
            echo "<tr>";
            for ($j=0; $j<mysql_num_fields($rs); $j++) {
                    echo "<td>".$row[$j]."</td>";
            }
        echo "</tr>";
      }
    echo "</table>";
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You simply need an array of Compactdisk objects.

Compactdisk[] cds = new Compactdisk[5];

You can add a cd like so

cds[0] = new Compactdisk();

and you can still access the object by array reference like so:

cds[0].getName();

When working in a loop, you will want to use a counter variable for the array index:

int cdCount=0;
String nameInput = input.next();
while (!nameInput.equalsIgnoreCase("STOP")){
   cds[cdCount] = new Compactdisk();
   cds[cdCount].setName(nameInput);
... // set other properties

   cdCount++;
   System.out.print("Enter CD Name or STOP to Exit: ");
   nameInput = input.next();
} // end of while loop

Does that make more sense? You actually store the Compactdisk objects in the array, then you can access any method you want on them.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Also, it looks confusing. I'll give a pre-emptive sigh for the dozens of questions on this forum...

Yes, there is a lot of info in the Sun tutorial and that volume might actually a bit harder to understand the bare basics. You may want to look at this info first to get a quick take on the basics of JSP:
http://www.jsptut.com/

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

"Enterprise Edition" is just the name they gave to their collection of classes for web and "enterprise" services. They are separate from the Standard Edition (regular) java classes and require an application server (somewhat like a web server) architecture for their use. Tomcat is one such server that allows you to interact with servlets and JSP pages. It can be used by itself or integrated with a web server such as Apache.

In the section "About The Examples" (http://java.sun.com/javaee/5/docs/tutorial/doc/About5.html#wp87965 ), you will find links to download all you need to get started: J2SE, J2EE, and Netbeans (an development tool to write, deploy, and test your code).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, if you know what a red-black tree is, you define a class for the nodes, a collection for those node, and the various methods to add, remove, search and print those node.

We can't simply do your homework for you. Post code and questions and someone can probably help.