Cerberus 17 Junior Poster

I would use an array of ints. Then loop through the length of the array. Then the nested loop output the numbers from the end of the array back to the beginning using the first loop as the counter to denote how many elements need printing.

Cerberus 17 Junior Poster

You could just style the tr, td and th tags

tr{
    background: white;
}

etc

Cerberus 17 Junior Poster

I'll give you a simple example..

Imagine a class:

public class Animal{
   int legs;
   bool tail;
   public Animal(int legs, bool tail){
         this.legs = legs;
         this.tail = tail;
   }
   public void noise(){
      System.out.println("GROWL!");
   }
}

Now we can inherit an 'Animal' and 'override' its noise method.

public class Dog extends Animal{
   public void noise(){
      System.out.println("WOOF"!);
   }
}

Dog inherits all the functionality of Animal and customises the noise method. This is approaching another subject (Polymorphism).

Cerberus 17 Junior Poster

Do you have any parameters in the CDArtist classes contructor?

E.g.

public CDArtist(String artistname)
Cerberus 17 Junior Poster

I pulled out this object oriented tutorial that you might find quite good.

http://sepwww.stanford.edu/sep/josman/oop/oop1.htm

peter_budo commented: I do not fancy design of that site, but that idea of introducing OOP is good +7
no1zson commented: always trys to help +1
Cerberus 17 Junior Poster

I think that the Actor class isn't available to the compiler.

The bolded line is defining that the class has an 'Artist' as a member. Just the same as you might have a class 'shape' that has an Integer variable 'sides' (int sides). The Artist is a user defined class.

Cerberus 17 Junior Poster

TheGathering,
Compactdisk would be my vehicle, and Cdartist would be a car or truck.

The Compactdisk class is really the specification for a car (or Cd no artist) and Cdartist a specification of a truck (cd with an artist).

The car or truck is the object that you instantiate e.g.

Compactdisk cd = new Compactdisk();
Cerberus 17 Junior Poster

Your almost there you just need to handle the exception. Try this:

try
{
       totalValue = totalValue + cds[cdCount].getValue();    
}
catch(NullPointerException npe)
{
        //handle exception
}
Cerberus 17 Junior Poster

The first error is saying that the CD Class doesn't know about the other class. This line isn't really necessary anyway.

What i would do would make a float variable in the inventory class and every time you loop and insert another element into the array add it to the float: e.g.

float runningTotal = 0;

runningTotal = runningTotal + arrayelement[0]
Cerberus 17 Junior Poster

I don't think this is possible because your web browser requires the source and viewing the source code is a function of the browser.

Is there any particular reason you need to do this?

Cerberus 17 Junior Poster

I don't see how you can hide the source that gets sent to the client browser. Code within the PHP tags would be processed at the server end anyway. So data such as database login wouldn't be sent to the client machine anyway.

Cerberus 17 Junior Poster

You array program works great. I do have one suggestion though. At the moment you have an array of 5 elements but the loop continues until the user types stop. What would happen if there were six iterations? I would suggest using a for loop limiting the loops to five iterations. You could then implement an if(userinput == "stop") statement with a break statement to exit the loop prematurely.

Cerberus 17 Junior Poster

That is what I have spent most of the morning trying to accomplish, building off Ezzaral's suggestion.
At this point I am just not sure how or where to set up the get and set commands. I think I have wrapped my brain around most of the rest of it.

Both the get and set commands would belong to the class which would be instantiated to represent CD's.

Cerberus 17 Junior Poster

CIf I understand it correctly, it will still have me setting up the information inside the array myself and then just calling those values later.

Yes you would need to implement some kind of loop to set up each object (and hence the array) with user defined data.

Cerberus 17 Junior Poster

What i think you need to do is implement an array of a user defined class. Here is an example...

A class Shape with two attributes, which are set by the constructor and two methods to access those attributes.

public class Shape{
    
    String type;
    int sides;
    
    public Shape(String type, int sides){
        this.type = type;
        this.sides = sides;
    }
    
    public String getType(){
        return type;
    }
    
    public int getSides(){
        return sides;
    }
}

Then a class that instanciates two 'shapes' and puts them into an array of shapes.

public class GetShapes{
    Shape[] shapes;
    
    public GetShapes(){
        shapes = new Shape[2];
        
        //instantiate shapes
        Shape shapeOne = new Shape("Square", 4);
        Shape shapeTwo = new Shape("Triangle", 3);
        
        //add to array
        shapes[0] = shapeOne;
        shapes[1] = shapeTwo;        
        
        //output contents of array
        System.out.print(shapes[0].getType());
        System.out.println(" have " + shapes[0].getSides() + " sides");
        System.out.print(shapes[1].getType());
        System.out.println(" have " + shapes[1].getSides() + " sides");
    }
    
    public static void main(String[] args){
        GetShapes gs = new GetShapes();
    }
}

Hope that helps.

Cerberus 17 Junior Poster

To explain using a different example: imagine a queue of people each person has unique attributes e.g. name, age, address etc (just like each cd would). Each time a person joins the queue their attribute must be known and when they are they can then be added to the queue.

Cerberus 17 Junior Poster

Try to use the array in the inventory and then add CD's to the array during each loop.

Cerberus 17 Junior Poster

Thanks again :) got that working in frontpage.

Is there a means to use css so it's not in the head? Because that's where my issue was with changing navbar before, that i couldn't seem to add css into the header (nor headerinclude).
Thank you again :)

Yup just copy and paste the style code (delete the style tags completely) into a seperate file and call it something like mystyle.css. Then put the following code into the head tags...

<link rel="stylesheet" type="text/css" href="mystyle.css" />

Cerberus 17 Junior Poster

I'm not sure how you do three images but i'll start you off with a simple roll over button.

<html>
<head>
<title></title>
<style type="text/css">
    .usercp
    {
        background-image: url(usercp2.png);
        display: block;
        width: 50px;
        height: 30px;
    }

    .usercp a
    {
        display: block;
        width: 50px;
        height: 30px;
    }

    .usercp img {width: 50px; height: 30px; border: 0; }
    .usercp a:hover img{visibility:hidden}
</style>
</head>
<body>
    <div class="usercp">
        <a href=""><img src="usercp.png"/></a> 
    </div>
</body>
</html>
Cerberus 17 Junior Poster

Good solution.

Cerberus 17 Junior Poster

Here's a simplified way to do it in CSS.

<html>
<head>
<title></title>
<style type="text/css">
    a:link {
        text-decoration: none;
        color: red;
        background-color: yellow;
    }
    a:visited {
        text-decoration: none;
        color: black;
        background-color: blue;
    }
    a:hover {
        text-decoration: underline;
        color: green;
        background-color: gray;
    }
    a:active {
        text-decoration: none;
        color: silver;
        background-color: cyan;
    }
</style>
</head>
<body>
        <a href="http://www.daniweb.com">Daniweb</a>
</body>
</html>

You can change the colours around between the style tags.

This can be done using your own images using rollover buttons instead.

Cerberus 17 Junior Poster

I don't know, i'll have to have a think about it. Perhaps using an associative array.

Cerberus 17 Junior Poster

If you have some kind of description of the system a start might be to make a list of all of the nouns as candidate classes.

Cerberus 17 Junior Poster

this is really rough but i think you mean something along these lines

$sql = "select * from table name where ";
$start;

if(isset $_POST['name'])
{
    $sql = $sql . $_POST['name'];
    $start = 1;
}

if(isset $_POST['phone'])
{
    if($start ==1)
    {
        $sql = $sql . "and '". $_POST['name'] ."'";
    }
    else
    {
        $sql = $sql . $_POST['name'];
    }
}

$sql = $sql . ";";
Cerberus 17 Junior Poster

Do you just mean the sql statement?

Something like this...

$sql="select * from table where name = ' " . $_POST[name] . " ' ";
$sql = $sql . " and phone = ' " . $_POST[phone] . " ';";

Cerberus 17 Junior Poster

Did you create the jar file using a manifest file?

e.g. >jar cvfm myjar.jar manifest.mf *.class

Cerberus 17 Junior Poster

The error is saying that it can't find the 'main' method.

Did you try to run the '.Java' file?

try to run it without the extension

E.g.

java HelloWorld

instead of

java HelloWorld.java

Cerberus 17 Junior Poster

It works for me.

Is url a String?

Cerberus 17 Junior Poster

Try replaceAll() instead.

Cerberus 17 Junior Poster

I think that limiting user input is always good.

How about the JSpinner class. That should allow the user to input a large range of numbers (that you specify in the constructor).

Cerberus 17 Junior Poster

You could use component like a dropdown box to limit the users choices to a range of numbers.