Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Object Oriented Design for a small scale Banking application

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Location
    Stamford
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Object Oriented Design for a small scale Banking application

    Hello all,

    I am new to Object Oriented Programming and I want to improve my Object Oriented design skills by designing small applications. I am thinking of doing a banking application and have come up with the following design.

    I've written down the classes with attributes and methods. I've added the types for attributes but haven't thought about the method signatures yet. Please take a look and comment.

    Bank
    Attributes - Map<CustomerID, Customer> customers
    Methods - getCustomerDetails(), addCustomer(), findCustomer(), deleteCustomer(), openAccount(), closeAccount()

    Customer
    Attributes - String firstName, String lastName, String phoneNumber, Date DOB, String customerID
    Methods - generateCustomerID() , getFirstName(),setFirstName(),getLastName(),setLas tName(),getPhoneNumber(),setPhoneNumber()

    abstract Account
    Attributes - String accountID, AccountType accountType, AccountStatus accountStatus, double balance
    Methods - open(), close(), deposit(), withdraw(), getBalance()

    CheckingAccount extends Account
    Methods - open(), close(), deposit(), withdraw()

    SavingsAccount extends Account
    Attributes - double interestAccrued
    Methods - open(), close(), deposit(), withdraw(), calculateInterest()

    enum AccountType
    CHECKING, SAVINGS

    enum AccountStatus
    ACTIVE, CLOSED


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,357
    My Mood
    Hungover
    Thanks
    144
    Thanked 626 Times in 537 Posts

    Default Re: Object Oriented Design for a small scale Banking application

    Seems fine to me.

    I wouldn't worry too much about getting your design absolutely perfect. Anything you write now will look terrible to you in 6 months (this is true for everybody just learning how to code), so the best thing you can do is actually write code.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,659
    Thanks
    25
    Thanked 325 Times in 302 Posts

    Default Re: Object Oriented Design for a small scale Banking application

    How does Customer and Account interact?

    Also, it is not necessary to have AccountType when you have different classes for each account type. You can do it that way, but it is not necessary. If you do want both, you do not need to store an AccountType attribute. Instead, you can create an abstract method in the Account class called: "getAccountType()", and then in each implementing Account class (CheckingAccount and SavingsAccount), you can implement the getAccountType() method to just return the type for the class.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  4. #4
    Junior Member
    Join Date
    Jan 2014
    Location
    Stamford
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Object Oriented Design for a small scale Banking application

    Thanks for the feedback, Kevin and aussiemcgr.
    Quote Originally Posted by aussiemcgr View Post
    How does Customer and Account interact?
    I just realised I 've missed Accounts under Customer. Every customer will have one or more accounts and so a collection of accounts will be one of the attributes of the Customer. Does this sound right?
    Quote Originally Posted by aussiemcgr View Post
    If you do want both....
    OK. I will correct this.

  5. #5
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,659
    Thanks
    25
    Thanked 325 Times in 302 Posts

    Default Re: Object Oriented Design for a small scale Banking application

    Sounds correct. Just a list or something of Accounts in the Customer class.
    Tell me if what I said earlier doesn't make sense. I kind of rushed through it when I typed it.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  6. #6
    Junior Member
    Join Date
    Jan 2014
    Location
    Stamford
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Object Oriented Design for a small scale Banking application

    I am a bit confused as to how the customer would make the request to get his name or phone number changed. Should the bank class also have edit methods for all the attributes with each of those methods calling the corresponding setter method in the Customer class? I am not able to think of doing this any other way but I somehow don't feel that I am right?

  7. #7
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,659
    Thanks
    25
    Thanked 325 Times in 302 Posts

    Default Re: Object Oriented Design for a small scale Banking application

    It depends on the program flow. If you can get the Customer object which you are attempting to change, you can just invoke the Customer class's methods on the object you retrieve, based on what you are wanting to update about the customer.

    Alternatively, you could go the route of creating "update objects", but that will probably be a pretty bloated solution for what you are wanting to do. What I mean by an "update object" is a class like: "CustomerUpdate" which would contain the editable fields for a Customer object. You would create a CustomerUpdate for each update event, and then pass it to the Bank object. The Bank object would then process the CustomerUpdate object based on what values should be updated. This is a solution which is really only used for super-large scale things, so I would not recommend it for your purposes.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Similar Threads

  1. Object Oriented Programming
    By calebite207 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 17th, 2012, 11:27 AM
  2. Object oriented programming
    By merr78 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 9th, 2012, 12:32 AM
  3. 1 page object oriented design
    By Herah in forum Object Oriented Programming
    Replies: 6
    Last Post: December 29th, 2011, 10:30 PM
  4. Banking Application
    By mbouster in forum Object Oriented Programming
    Replies: 2
    Last Post: January 9th, 2011, 10:23 AM
  5. Object-oriented applet
    By mjpam in forum Object Oriented Programming
    Replies: 26
    Last Post: September 15th, 2010, 06:43 AM