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: Warehouse application?

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Warehouse application?

    Hello,

    I've recieved an "over the holidays" task to preform, that task is to create a "warehouse application" in Java but my instructions are, in all fairness, too lousy to get me started on it. So, I was wondering (and hoping) that maybe someone here could help me understand how i need to get started

    My instructions:

    "Create a warehouse application into which the user can, with the help of GUI, add items with Name, Quantity and Price in an array. One should be able to see these items as well as the total value of each item. Value = quantity*price.

    Furthermore a value for the warehouse total should be seen"


    Now i understand what the end result is supposed to be, a simple GUI with input boxes and either a TextArea or Panel for output. But I have, as mentioned, no idea how to get started with the actual functions.

    I've gotten as far as that i'll need to create a Class for it but that's about it...

    Would be very grateful if someone could try and explain to me what needs to be done.

    Thank you kindly


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Warehouse application?

    Hello and welcome to the forums.

    First, I would create the GUI. Take a look at this link:

    Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)

    When the GUI is complete, you can create the functionality.

    Take a look at our Java Code Snippets and Tutorials forum. There are code examples there.

    For example:

    http://www.javaprogrammingforums.com...ava-swing.html


    Post back with the code you have and we can take it from there..
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Warehouse application?

    Hi again,

    Seeing as the original instruction was, to me, insufficient, i asked for something more to go on and was told the following:

    "Create a class 'LagerVara' with constructor to set instancedata like name(String), quantity(int) and price(double) as well as get-methods to collect said instancedata"

    Allthough this helped a bit, i'm still a bit confused. Since the input data is supposed to be saved into an array and such I'm not entirely sure how to go about it.

    Here's what i've gotten so far (very basic still)

    This is the GUI in graphical view, TextArea to show information, TextFields to enter information, and a button.


    I haven't entered any actual coding into the GUI yet.

    The class, LagerVara, currently looks like this:

    public class LagerVara {
     
        private String namn=null;
        private double pris=0;
        private int antal=0;
     
     
     
    public LagerVara (String namn){
     
    }
     
    public LagerVara (double pris){
     
    }
     
    public LagerVara (int antal){
     
    }
     
    public String getNamn (String namn){
        return ;
    }
     
    public double getPris (double pris){
        return ;
    }
     
    public int getAntal (int antal){
        return ;
    }
     
    }

    What i'm currently pondering is, do i put the Array (in which the information is to be stored) in the class or GUI? I'm leaning towards putting it in the class?

    And, if it goes in the class, won't i need set-methods as well?


    PS. Sorry for the crude images, Paint is currently all i have to work with

    Edit: forgot to mention, I'm doing all of this using NetBeans 6.9.1 just so i've said that too
    Last edited by cretorian; December 30th, 2010 at 07:28 AM. Reason: Forgot to mention..

  4. #4
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Warehouse application?

    Hi again,

    Just thought I'd wrap this up, solved the "puzzle" so to say ^^

    What i did was this:


    Class:

    public class LagerVara {
     
        private String namn;
        private double pris;
        private int antal;
     
    public LagerVara (){
        //tom konstruktor
    }
     
     
    public LagerVara (String namn){
    this.namn=namn;
    }
     
    public LagerVara (double pris){
    this.pris=pris;
    }
     
    public LagerVara (int antal){
    this.antal=antal;
    }
     
    public String getNamn (){
        this.namn=namn;
        return this.namn ;
    }
     
    public double getPris (){
        this.pris=pris;
        return this.pris ;
    }
     
    public int getAntal (){
        this.antal=antal;
        return this.antal ;
    }
     
    public void setNamn (String namn){
        this.namn=namn;
     
    }
     
    public void setPris (double pris){
        this.pris=pris;
     
    }
     
    public void setAntal (int antal){
        this.antal=antal;
     
    }
     
     
     
    }

    and the GUI code turned out like this:

    LagerVara l=new LagerVara();
    String LagerVaror [][]=new String [30][4];
    double total=0;
    double lvarde=0;
    int index=0;
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            // TODO add your handling code here:
            jTextArea1.setText(null);
     
            l.setNamn(jTextField1.getText());
            l.setPris(Double.parseDouble(jTextField2.getText()));
            l.setAntal(Integer.parseInt(jTextField3.getText()));
     
     
     
            LagerVaror[index][0] = l.getNamn();
            LagerVaror[index][1] = String.valueOf(l.getPris());
            LagerVaror[index][2] = String.valueOf(l.getAntal());
            LagerVaror[index][3] = String.valueOf((l.getPris()*l.getAntal()));
            index++;
     
            total=l.getPris()*l.getAntal();
     
            for (int i = 0; i < index; i++){
            jTextArea1.append("Varunamn: " + LagerVaror[i][0] +"     "
                    + "Pris: " + LagerVaror[i][1] +"     "
                    + "Antal: " + LagerVaror[i][2] +"     "
                    + "Värde: " + LagerVaror[i][3] +"\n");
            total=total+total;
            }
            jTextArea1.append("LagerVärde: " +total);
     
        }


    Now to have some fun the rest of the day before diving into the next problem tomorrow

    Thanks for linking me to the code-snippets section, was most helpful

Similar Threads

  1. Quiz application
    By JonoF in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: May 10th, 2010, 06:06 AM
  2. [SOLVED] [help] the application file (.jad) for application does not appear to be the ....
    By ordinarypeople in forum Java ME (Mobile Edition)
    Replies: 0
    Last Post: April 4th, 2010, 03:50 AM
  3. Java Application Help...
    By Brian in forum Java ME (Mobile Edition)
    Replies: 0
    Last Post: March 25th, 2010, 07:38 AM
  4. Replies: 0
    Last Post: December 3rd, 2009, 04:43 PM
  5. RMI over SSL Client application
    By boilerchicken in forum Java Networking
    Replies: 0
    Last Post: November 10th, 2009, 07:52 AM