Search:

Type: Posts; User: curmudgeon

Search: Search took 0.11 seconds.

  1. Replies
    17
    Views
    1,572

    Re: writing a class

    Muuuuuuuuuuuuuuch better!
  2. Replies
    17
    Views
    1,572

    Re: writing a class

    This is the current object. The one you're creating in this constructor.
  3. Replies
    17
    Views
    1,572

    Re: writing a class

    This is your constructor? This doesn't make any sense at all. Again throwing code against the wall at random and seeing what sticks is not a viable way to program. Please delete this and re-look at...
  4. Replies
    17
    Views
    1,572

    Re: writing a class

    For a copy constructor you should copy the state of the other object. For instance:



    class Foo {
    private int baz;
    private int bar;

    public Foo(Foo other) {
    // get the values...
  5. Replies
    17
    Views
    1,572

    Re: writing a class

    In the code above, you're getting the values from pi, but not doing anything with them you're simply getting them and discarding them. You want to *use* those values to set the state of the new Pizza...
  6. Replies
    17
    Views
    1,572

    Re: writing a class

    No. You're pulling out "magic numbers" from thin air, 12.00 and 4.00, and you're totally ignoring the values held by pi. Why not use pi when setting diameter and price?



    No. Again, do you...
  7. Replies
    17
    Views
    1,572

    Re: writing a class

    OK, create "an exact copy..." the newly created Pizza's fields should match those of the Pizza passed into the constructor.

    So first off: what are the two fields I'm talking about?
    How would you...
  8. Replies
    17
    Views
    1,572

    Re: writing a class

    It looks like you're trying to write a copy constructor where you usually copy the properties of one object into the newly created Pizza object. But you're doing nothing with the parameter, pi, and...
Results 1 to 8 of 8