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: Permanently change variable values based on user input.

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

    Default Permanently change variable values based on user input.

    Hey everyone, I've been working on a project with a friend of mine and we're trying to create a program that spits out information based on information about a situation that the user is currently in. We have all these things that have a certain probability to be chosen based on a score that we have created. We're trying to implement a system in which after all the situations are over the user will tell the computer whether or not the information it put out was good or bad. Based on this answer the computer will change the score of the sets of information that it chose so that it knows they worked in that situation. I'm decently new to java and I don't know of any way to permanently change a variable in a system without going in and changing it in the actual code. Does anyone have any tips?


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Permanently change variable values based on user input.

    I don't quite understand what you are trying to do, or what your question is

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Permanently change variable values based on user input.

    way to permanently change a variable in a system
    Nothing is permanent in or on a computer. Every value can be edited or rewritten.
    You'll have to explain where the value is that you want to change and how you expect that value to be kept unchanged in the future.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Member
    Join Date
    Jun 2012
    Location
    Left Coast, USA
    Posts
    451
    My Mood
    Mellow
    Thanks
    1
    Thanked 97 Times in 88 Posts

    Default Re: Permanently change variable values based on user input.

    Maybe you can try something like the following:

    1. When the application starts, have it look for a certain file in a certain place with certain contents.

    2. If the file does not exist, set the relevant variable values to appropriate defaults.

    3. If the file does exist, read in the values previously saved in the file.

    4. When the program want's to "change the score of the sets of information" (whatever that means), have the program write the relevant values to the file.



    Of course, the change won't be truly "permanent," but it will say in effect until the next time the program decides that it needs to "change the score of the sets of information" (whatever that means).

    Furthermore, if you make the file a human-readable (text) file, you can create the file off-line (with a text editor) with whatever values you have previously found (by simulation or whatever) before you run the application.



    Cheers!

    Z

Similar Threads

  1. Replies: 1
    Last Post: May 16th, 2012, 05:15 PM
  2. Replies: 13
    Last Post: December 6th, 2011, 02:17 PM
  3. Trying to show change on Image based on pixel values
    By javaGurl in forum Algorithms & Recursion
    Replies: 1
    Last Post: September 20th, 2011, 03:49 PM
  4. Allowing user to input variable.
    By That1guy in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 15th, 2010, 11:30 PM
  5. JTable Updating String Values from User Input
    By aussiemcgr in forum AWT / Java Swing
    Replies: 5
    Last Post: August 3rd, 2010, 01:48 PM