Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By JosAH

Thread: Make a class that does this:

  1. #1
    darthvader45 is offline Member
    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Question Need help on this

    Ok, here's what I need to do:
    Part 1:
    Create an abstract class named “Customer”.
    Add 2 private fields to the class, “name” and “id”.
    Add a constructor that takes 2 arguments, “aName” and “aId”.
    Add the following abstract method “public abstract double discount();”

    Part 2:
    Create a Child class of Customer named “OnlineCustomer”.
    Add a constructor that takes 2 arguments, name, id.
    Write the body of the inherited abstract discount method.
    Online customers get a 10% discount.

    Part 3:
    Create a JFrame class for your user interface named “CustomerJFrame”.
    I can create the button, but have trouble with the text fields and JLabels. I need the first JLabel and text field lined up on the first row, then a second jlabel and text field on the row below it.
    I then add a button below that does this:
    When the button is selected, create the OnlineCustomer object using the name and id from your JTextFields. Display the name, id and discount in the OnlineCustomer object in the message JLabel.

    In the end, it should look like these pictures:
    Make a class that does this:-finalscreenshot1.png

    I think I've got the right code for part 1, but I need help on part 2 and 3. What I got won't run.
    Last edited by darthvader45; 12-09-2012 at 04:37 PM. Reason: More info

  2. #2
    sethe23 is offline Member
    Join Date
    Oct 2012
    Posts
    15
    Rep Power
    0

    Default Re: Need help on this

    What errors do you have, it would be nice to have a starting place because creating the whole GUI for demonstrative purposes is kind of a pain.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,416
    Rep Power
    20

    Default Re: Need help on this

    Quote Originally Posted by darthvader45 View Post
    I think I've got the right code for part 1, but I need help on part 2 and 3. What I got won't run.
    Was that code from Create this in Eclipse: Create an abstract class named Customer - JustAnswer ?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    darthvader45 is offline Member
    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Default Re: Need help on this

    Quote Originally Posted by DarrylBurke View Post
    I believe so, and my error is simple: When I run it, the program immediately exits. It won't even display, it just quits. I set the jframe to visible and everything.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default Re: Make a class that does this:

    What is 'advanced' about this question?

    kind regards,

    Jos
    Jire likes this.
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    kaydell2 is offline Senior Member
    Join Date
    Dec 2012
    Posts
    106
    Rep Power
    0

Similar Threads

  1. Make an object from a class once
    By OddOne in forum New To Java
    Replies: 7
    Last Post: 07-03-2012, 05:04 PM
  2. how to make a resource class
    By Steineronie in forum New To Java
    Replies: 2
    Last Post: 02-11-2012, 04:54 AM
  3. Can't make a java .class to a .jar
    By TheDarkMagician in forum New To Java
    Replies: 4
    Last Post: 02-19-2011, 11:45 PM
  4. Deleted Class template code. Now I cant make class.
    By AcousticBruce in forum IntelliJ IDEA
    Replies: 0
    Last Post: 01-11-2011, 10:52 PM
  5. Please help, need to make my class static.
    By sumak in forum New To Java
    Replies: 1
    Last Post: 04-19-2008, 07:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •