DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2005

    Highschool Java Class Investigation

    Hello everybody I just entered this programming class in my high school, and I'm totally lost.

    They're doing Class and Objects right now.

    I would like to get help on this one problem:

    Develop and implement a class Account that represents a savings account. An Account object should have three attributes: the name of the account, the owner of the account, and the current balance. The class should provide the following constructors behaviors.

    Name(): configures a new account with name "name", owner "owner", and balance 0.
    Name(String s, String t, double n): configures a new account with name s, owner t, and balance n.
    void deposit(double n): adds amount n to the current balance of the associated account.
    void withdraw(double n): subtracts amound n from the current balance of the associated account.
    void close():zeroes out the account balance, sets the owner to "".
    String getAccountName(): returns the name of the associated account.
    String getOwner(): returns the owner of the associated account.
    double getBalance():returns the balance of the associated account.
    void setName(String s): sets the name of the associated account to s.
    void setOwner(String s): sets the owner of the associated account to s.
    String toString(): returns a textual representation of the attributes of the associated account.
    Besides that the teacher doesn't want anyone to add anything into the code, just what it says up there.

  2. #2
    Join Date
    Dec 2004
    San Bernardino County, California
    So your "attributes" are your class's data members, and your teacher has given you the declarations of the class's method members. You have the basic structure you need. I expect your reference materials will help you with the rest ... by which you define your constructors and various methods.
    Last edited by nspils; 10-12-2005 at 12:08 AM.

  3. #3
    Join Date
    Oct 2005


    Its my humble suggestion that you do not take help on this one by anyone. If your teacher do not want anyone to add anything into existing code than simply create another class which extend the provided one and write concrete methods there. Infact you should put provided declerations into an interface and than you a class which implements it.

    Again it be much better if you go about solving this one by yourself.


  4. #4
    Join Date
    Nov 2004
    Basically Account will have three private variables;

    private String name;
    private String owner;
    private double balance;

    The methods specified will set, return of modify these.

    I'm not sure why your teacher wants you to have a special method (Name) that is
    really just doing the job of a constructor. (I may have missed out
    on some "new" java thinking here...or is he planning on using Reflection later ?)
    Last edited by sjalle; 10-12-2005 at 06:07 AM.
    eschew obfuscation

Similar Threads

  1. Replies: 5
    Last Post: 10-17-2002, 01:58 PM
  2. Replies: 205
    Last Post: 09-26-2001, 01:37 PM
  3. Calling base class methods
    By GR in forum Java
    Replies: 1
    Last Post: 11-09-2000, 05:38 PM
  4. Run a dos command from a Java class
    By Alex Omar Pagan Ortiz in forum Java
    Replies: 2
    Last Post: 10-03-2000, 12:09 PM
  5. Java Class Libraries
    By Peggy Klinger in forum Java
    Replies: 0
    Last Post: 04-11-2000, 01:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.