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

Thread: Leetment's schoolproject - Need ideas and help!

  1. #1
    Junior Member
    Join Date
    May 2012
    Location
    Sweden
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Leetment's schoolproject - Need ideas and help!

    Bear with me, my English is not that good because it's not my native tongue.

    I started this thread to get some ideas, critique and such for a Java school project I am working on that should be done in a couple of weeks. So I am working on a concept on a program I could make, it's not very advanced and pretty much the basics but I could need some comments and idea as I work on it how to solve stuff etc.

    The project must include these methods(?):

    *Search function
    *ArrayList
    *Load/Save to file
    *Sort function

    What I got told is that I should be able to save stuff from a file, then load it to sort it or search for something in the file. I have a hard time figuring out how to approach all these methods and bring them into one working program that use all these things, not just a program that can load any of these methods.

    What I had in mind is to make some kind of program that can keep track of your bills? You can either load or create a file when the program start and then you enter values somehow of what you've purchased and save it to the file which you later can search in and sort to see what you've spent most money on that month or so for example.

    Does this sound like something I could do within 2 weeks, is it any other concept of a program I could use instead? Is this thread misplaced?


    Thanks in advance, hopefully I can create something awesome with your help.

    Leet.


  2. #2
    Junior Member
    Join Date
    Feb 2012
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    I'd say a program like that could certainly be done in two weeks. I think the first thing you need to do is start working on it, and then you will probably develop a more concrete idea of where you want it to go. If I think a project is large or overwhelming, I find the best thing to do is just start it.

  3. #3
    Junior Member
    Join Date
    May 2012
    Location
    Sweden
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    Quote Originally Posted by BloomingNutria View Post
    I'd say a program like that could certainly be done in two weeks. I think the first thing you need to do is start working on it, and then you will probably develop a more concrete idea of where you want it to go. If I think a project is large or overwhelming, I find the best thing to do is just start it.
    I'm on it! I've created the methods how to load/save files already and now need to figure out how to make a JOptionPane popup with a dropwdown menu and input window, does that make sense? I think I should be able to make it look okay with breakline... for example:

    Food: 50 dollar
    Clothes: 39 dollar
    Bills: 100 dollar

    Now I get the question, can I make those "labels" to variables in a textfile and be able to sort them, search in them and maybe even edit them.

  4. #4
    Junior Member
    Join Date
    May 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    Could you please rephrase your question? Since you're new to this, I'll tell you that I think you'll find you get better responses in programming forums if you ask specific, concrete questions.

  5. #5
    Junior Member
    Join Date
    May 2012
    Location
    Sweden
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    Quote Originally Posted by Miranden View Post
    Could you please rephrase your question? Since you're new to this, I'll tell you that I think you'll find you get better responses in programming forums if you ask specific, concrete questions.
    I try to be as clear as I am.


    I want the user to put in how much money he spent on what and that will be saved in a textfile so I cant sort or search in it later. Does this make more sense?

  6. #6
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    You need to create a writer and a reader method. The writer will write the information to a text file in some sort of formatted way that makes sense to you. Then the reader will parse through your text file, retrieving the information based on how you formatted it, and probably storing the data in some sort of Object which you can then put in an Array or a List for you to sort, or search, or whatever.

    In order to search, sort, or edit data in a text file, you have to read and rewrite it accordingly. Data in a text file cannot be manipulated without reading it out of the text file first (as far as I know).
    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/

  7. #7
    Junior Member
    Join Date
    May 2012
    Location
    Sweden
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    Thank you aussiemcgr!

    I've managed to write the method that load, create and tomorrow I will write the write to/save save method.


    A friend of mine said that I will need two arrays to get the sort and search to work, which not really make sense, he said I need one that list all the "stuff i spent money on" and how much... Cant I write what cost what in one array list?

  8. #8
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    You don't need two arrays. Are you storing your data in an Object that you created?
    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/

  9. #9
    Junior Member
    Join Date
    May 2012
    Location
    Sweden
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    Quote Originally Posted by aussiemcgr View Post
    You don't need two arrays. Are you storing your data in an Object that you created?
    What do you mean? I googled object but I do not understand really what it is?

  10. #10
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    An Object is essentially a way to store related data in an organized way. I suggest you reread your textbook. It is probably the first chapter. For your project, you would probably create some sort of Object named Item or something, which had a String (for the name of the item) and an int or double (for the price of the item). Then when you read the data from your file, you would create Item objects and set its variables accordingly, and then add that new Item Object into an Array or List. Once you have the Item objects in the array, you can search by the Item's name, or price, or whatever to find any specific Item Object.
    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/

  11. #11
    Junior Member
    Join Date
    May 2012
    Location
    Sweden
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    Quote Originally Posted by aussiemcgr View Post
    An Object is essentially a way to store related data in an organized way. I suggest you reread your textbook. It is probably the first chapter. For your project, you would probably create some sort of Object named Item or something, which had a String (for the name of the item) and an int or double (for the price of the item). Then when you read the data from your file, you would create Item objects and set its variables accordingly, and then add that new Item Object into an Array or List. Once you have the Item objects in the array, you can search by the Item's name, or price, or whatever to find any specific Item Object.
    For some odd reason we don't use textbooks but I've downloaded two different to look closer on the matter. So I basically need an object for write information to the file and then another object to put the information in the file into the array/list ?

  12. #12
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    You can create one Object that serves both purposes. Objects have variables, and setter and getter methods to properly access those variables. When you read from the file, you would be using the setter methods. And when you write to the file (as well as requesting for the values of variables in other parts of your program), you would be using the getter methods.

    Do you know any other programming languages? It might be easier to describe Objects if I can relate it to something you are already familiar with.
    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/

  13. #13
    Junior Member
    Join Date
    May 2012
    Location
    Sweden
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    Quote Originally Posted by aussiemcgr View Post
    You can create one Object that serves both purposes. Objects have variables, and setter and getter methods to properly access those variables. When you read from the file, you would be using the setter methods. And when you write to the file (as well as requesting for the values of variables in other parts of your program), you would be using the getter methods.

    Do you know any other programming languages? It might be easier to describe Objects if I can relate it to something you are already familiar with.
    I downloaded an E-book to help me with objects but I think it make more sense now still got some questions about it.

     
    class Movie {
    String title;
    String genre;
    int rating;
    void playIt() {
    System.out.println(“Playing the movie”);
    }
    }
    public class MovieTestDrive {
    public static void main(String[] args) {
    Movie one = new Movie();
    one.title = “Gone with the Stock”;
    one.genre = “Tragic”;
    one.rating = -2;
    Movie two = new Movie();
    two.title = “Lost in Cubicle Space”;
    two.genre = “Comedy”;
    two.rating = 5;
    two.playIt();
    Movie three = new Movie();
    three.title =Byte Club”;
    three.genre = “Tragic but ultimately uplifting”;
    three.rating = 127;
    }
    }


    I understand that the class is used to store the variables but I am not sure how those things run together? I see no connection between two methods in the code. :s

  14. #14
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    You can think of a class as an Object. For the sake of keeping things simple: class = object.
    Every time you create a new class, you are creating a new Object type.

    So, in your above code, you have a Movie class and a MovieTestDrive class. So, you have created two new types of Objects: a Movie Object and a MovieTestDrive Object. Most of time, when you create a new class, you also create a Constructor for the Object that belongs to the class. If you do not create a Constructor, your Object is given a default Constructor (a Constructor without any arguments).

    So, when you create a new Movie Object (by saying: Movie one = new Movie();), the new Movie Object is given a String variable named title (set to null by default), another String variable named genre (set to null by default), an int variable named rating (set to 0 by default), and a method that returns nothing named playIt().

    Does all of that make sense? If so, what are you still not 100% comfortable with? (I'm unsure where to go from here based on what you do and don't understand)
    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/

  15. #15
    Junior Member
    Join Date
    May 2012
    Location
    Sweden
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    I am getting the hang of how it works now I think.

    A class is the blueprint for an object, while the object is just an entry in the arraylist?

     public class ProjektUtgifter {
       String ThingYouSpentMoneyOn;
       int HowMuchItCosted;
     
     
        public static void main(String[] args) throws IOException {
            startUp();
        }


    I then make a method that look like this?

    class ProjektUtgifter {
    public static void startUp(); {
     
    expense d = new expense();
    d.ThingYouSpentMoneyOn; = Clothes;
    d.HowMuchItCosted; =  500;
    Last edited by Leetment; May 18th, 2012 at 05:43 PM.

  16. #16
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Leetment's schoolproject - Need ideas and help!

    I imagine you would get an error for that statement. When you type this: public static void startUp(), the compiler is expecting you to create a method, but when you put a semicolon immediately after there (which is what you did), it doesn't really mean anything (it would if you added the abstract identifier and made the class abstract, but that is way beyond the scope of this question).

    If you wanted to create a method, you put the identifiers in front (public, static, void are all identifiers) and you don't put a semicolon after it. If you are wanting to call a method, you don't put the identifiers in front and you do put a semicolon after it.

    For example:
    public void someMethod() { //This is creating a method
    }
    ...
    someMethod(); //This is calling a method

    Note: The code I just posted will not compile, it was just to illustrate the difference
    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. Game Ideas...
    By SupportIsPower in forum Java Theory & Questions
    Replies: 0
    Last Post: March 11th, 2012, 03:03 PM
  2. Any ideas?
    By ahender1 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 2nd, 2012, 03:58 PM
  3. Any Program Ideas?
    By Java Programmer in forum Java Theory & Questions
    Replies: 7
    Last Post: January 18th, 2012, 08:05 AM
  4. I need ideas on how to read this
    By thursgun in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: April 21st, 2010, 09:31 PM
  5. Any ideas for begginer?
    By SwEeTAcTioN in forum Java Theory & Questions
    Replies: 11
    Last Post: October 27th, 2009, 03:28 AM