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 4 of 4

Thread: Question about my project

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Question about my project

    Hi,

    I have a project about a cash for metals company.
    I created 3 classes to begin with: a super class Customer and 2 subclasses that inherit from the superclass. Each customer has a unique id.

    Now i have to create a class named Account which will contain an account number. My question is how do i tie the unique account number with the unique id. What strategy should i follow. Customers will have one account but can have multiple transactions and are created each time a customer is created?

    Thanks for the help.


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Question about my project

    1. What are your two classes (subclasses)?
    2. Create an independent Account class and create it's object in your Customer class. In your Account class, create a method that will verify the uniquness of Account Number. Call it at new Customer creation.

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Question about my project

    Hi Mr. 777,

    I have Customer as super class, and i created PersonalCustomer and ComercialCustomer as subclasses that inherit from Customer.
    I also have a class Client that contains the main and an ArrayList that stores customers.

    Right now i am working on the Account class.

    These are the requirements for it.
    1) Create an account for each customer. An account will have an account number (long),
    balance (double), date opened (calendar) using the current date/time, and interest rate
    (double).
    2) Accounts have a default balance of 0 (balances cannot be less than 0) and a rate of 3%.
    3) Get methods should be created for each attribute.
    4) Accounts have two methods: makeDeposit (returns void) and makeWithdrawal (returns actual
    amount withdrawn from the account).
    5) Note the account should be created when the customer is created.

    This is what i have so far. Am i on the correct track?


    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
     
    public class Account 
    {
     
    	public static final double DEFAULT_ACCOUNT_BALANCE = 0;
        public static final double DEFAULT_INTEREST_RATE = .03;
        private static long aNumber;
        private double balance;
     
        Calendar cal1 = Calendar.getInstance();
     
        public Account()//default
        {
        	balance = DEFAULT_ACCOUNT_BALANCE;
        }
     
        public Account (long number, double balance)
    	{
     
    		aNumber = number;
    		this.balance = balance;
     
    	}
     
    	public static void setAccount (long number)
    	{
    		number = (long)(Math.random()*100000000);
    		aNumber = number;
    	}
     
    	public void setBalance(double aBalance)
    	{
    		balance = aBalance;
    	}
     
    	public double getBalance ()
    	{
    		return balance;
    	}
     
    	public long getANumber ()
     
    	{
    		return aNumber;
    	}
     
    	public int getDate()
    	{
    		return cal1.get(Calendar.YEAR) + cal1.get(Calendar.MONTH) + cal1.get(Calendar.DAY_OF_MONTH);
    	}
     
     
    	public String toString()
    	{
    		return getClass() + "\nAccount: " + aNumber + " balance: " + balance + " Date: " + cal1;
    	}
     
    	public void  makeDeposit (double amount)
    	{
    		balance = balance + amount;
    		return;
    	}
     
    	public double makeWithdrawal(double wAmount)
    	{
    		return wAmount;
    	}
     
    	public static void newCustomer (ArrayList<Customer> customers)
    	{
    		for (int i = 0; i < customers.size(); i++)
    		{
     
    		}
    	}
    }

  4. #4
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Question about my project

    Why are your class variables static? Though it's not wrong but it is strongly discouraged coz it kills OOP major functionality.
    Well, all seems right to me, but where is account number and where are you checking it for uniquness?

Similar Threads

  1. Little help with this project please
    By Darkcore123 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 13th, 2011, 05:08 PM
  2. project
    By rafishaik999 in forum The Cafe
    Replies: 4
    Last Post: December 22nd, 2010, 12:45 PM
  3. Can anyone help me on my project?
    By alesana514 in forum Paid Java Projects
    Replies: 1
    Last Post: December 16th, 2009, 09:24 AM
  4. Need Help With Project
    By jstew132 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 11th, 2009, 07:15 PM
  5. Need a project
    By helloworld922 in forum Project Collaboration
    Replies: 6
    Last Post: July 31st, 2009, 08:30 AM