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

Thread: Extensive help with banking simulator

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Extensive help with banking simulator

    Hi community! I'm new here, and not native English, so forgive any mess in language.

    I've got an assignment where I'm supposed to write a banking simulator, i.e a program where you manage customers and accounts. It is a quite extensive program using multiple classes and neither the lessons nor the course literature provide me with the information I need. ArrayList is compulsory to use.

    It's hard to explain the entire assignment in text, so I would be very happy if a helpful soul could add me on Skype. Not necessary to make a call but it's easier to discuss there where I can show my screen and such in real-time. If you're a troll, I'll block you, do mind. Send me a PM here and I'll send my Skype nickname. (If you happen to be Swedish and/or use Eclipse, it would be awesome)

    Thanks in advance.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Extensive help with banking simulator

    Do you have any specific questions about your assignment?
    Please post your code and any questions about problems you are having.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Extensive help with banking simulator

    It's a huge bunch of questions, I really don't know where to start...I'll try with something.

    This is the customer class. It is my first attempt of doing class with a constructor, so I really don't have any idea of what I'm doing... Down at the get-method, I get an error stating "Cannot make a static reference to the non-static field pNr". Why is that? (Btw, pNr stands for "person-number", it's birth date + four digits, like mine is 940430-4322. It's a Swedish thing.)

    public class Customer {
     
    	private static String name;
    	private long pNr;
     
    	public Customer (String n, long p){
    		name = n;
    		pNr = p;
    	}
     
    	public static void setName(String n){
    		name = n;	
    	}
     
    	public void setPNr(long p){
    		pNr = p;
    	}
     
    	public static String get(){
    	String namePNr = (name+"\t"+pNr);		
    		return namePNr;
    	}
    }
    Last edited by Minilena; February 3rd, 2013 at 02:42 PM. Reason: Looking like code!

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Extensive help with banking simulator

    Cannot make a static reference to the non-static field
    All the variables and methods in the class should not be static. Remove the static.
    static is used when there will only be one variable that will be shared by all instances.
    non static variables only exist in an instance of the class and can not be used by static methods.

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Feb 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Extensive help with banking simulator

    Without the static, I get an error message in the calling method. "Cannot make a static reference to the non-static method get() from the type Customer"
    Calling method looks like this:
    private String getCustomer(){
    		String name = Customer.get();
    		return name;
    	}

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Extensive help with banking simulator

    Customer.get();
    Instead of using the name of a class: Customer, use a reference to an instance of the Customer class.

    I'm assuming Customer is a class and that get() is a method in the Customer class.

    You should not be using static for anything. The one exception is the main() method.

    Read about static here:
    http://docs.oracle.com/javase/tutori...classvars.html
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Need some help with my Banking program
    By bankston13 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: September 17th, 2012, 09:04 PM
  2. banking system
    By preeti in forum Java Theory & Questions
    Replies: 3
    Last Post: August 11th, 2011, 01:25 PM
  3. Banking Application
    By mbouster in forum Object Oriented Programming
    Replies: 2
    Last Post: January 9th, 2011, 11:23 AM
  4. I need extensive help with my java assignment
    By MoshMoakes in forum What's Wrong With My Code?
    Replies: 0
    Last Post: December 12th, 2009, 07:44 PM

Tags for this Thread