Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

plz this : need help

tollitolli Posts: 44Member
plzzzz any body can help me in this issue:

my pblm is simply the following:

first of all i neeed to make a file processing program with GUI that simulates a college database. the program should simply allow adding students, modifying student's information, providing course offering, in addition to enrolments, adding grades, printing transcripts:

i thought of the following:

i implemented class student that provides us the records of students, another one for courseOfferingsRecords and I want to read records, add records, delete and modify records in files:

I know how to read and output the records from files into a command prompt but dont know how to do it in GUI and how to read record lines with different info (ex: name of student as a string and his ID number as an int...) and list them in a text are or an optionPane (popup). I dont want the serializing thing...


plzzzzz any help????? thanksssssss

Comments

  • zibadianzibadian Posts: 6,349Member
    : plzzzz any body can help me in this issue:
    :
    : my pblm is simply the following:
    :
    : first of all i neeed to make a file processing program with GUI that simulates a college database. the program should simply allow adding students, modifying student's information, providing course offering, in addition to enrolments, adding grades, printing transcripts:
    :
    : i thought of the following:
    :
    : i implemented class student that provides us the records of students, another one for courseOfferingsRecords and I want to read records, add records, delete and modify records in files:
    :
    : I know how to read and output the records from files into a command prompt but dont know how to do it in GUI and how to read record lines with different info (ex: name of student as a string and his ID number as an int...) and list them in a text are or an optionPane (popup). I dont want the serializing thing...
    :
    :
    : plzzzzz any help????? thanksssssss
    :
    I would make a JPanel for the student record. In that panel place JTextFields and JLabels to show/edit the fields. That panel should also feature a button to apply the the changes to the student record. This then becomes a simple number of assignment statements, for example:
    [code]
    student.name = nameField.getText();
    student.birthDay = birthDayField.getText();
    String s = studentIDField.getText().Trim();
    if (s != "") student.id = Integer.parseInt(s);
    [/code]
    The same can be done for other records.
  • tollitolli Posts: 44Member
    first thanks ... What I understood is that u r suggesting to print each part of the record into a separate JTextField : However, I want to Print each line in the file in one TextField with each line being one record: Now I think that we may use the code that I presented previously:

    String S, name;
    String S2="";
    name=jTextField1.getText().trim();
    try{
    BufferedReader in = new BufferedReader ( new FileReader(name));
    int i=0;
    while ((S=in.readLine())!=null)
    {
    i++;
    S2+=S+" ";
    if (i%3==0)
    S2+="
    ";
    }
    in.close();
    } catch (IOException e) {
    JOptionPane.showMessageDialog(this,"File NOT Found");
    }
    jTextArea1.setText(S2);


    then each line will be stored in S and the whole file will be stored in S2 string. Is that right?????

    i dont know maybe there is the pblem of differentiating the different parts of eachh record(ex differentiating between the name and ID....)then i should think of transforming the string S into the object Student (for e.g.) ....

    please any suggestions?? And if am understanding things in a wrong way plz help me and correct me !

    thanks a lot

  • zibadianzibadian Posts: 6,349Member
    : first thanks ... What I understood is that u r suggesting to print each part of the record into a separate JTextField : However, I want to Print each line in the file in one TextField with each line being one record: Now I think that we may use the code that I presented previously:
    :
    : String S, name;
    : String S2="";
    : name=jTextField1.getText().trim();
    : try{
    : BufferedReader in = new BufferedReader ( new FileReader(name));
    : int i=0;
    : while ((S=in.readLine())!=null)
    : {
    : i++;
    : S2+=S+" ";
    : if (i%3==0)
    : S2+="
    ";
    : }
    : in.close();
    : } catch (IOException e) {
    : JOptionPane.showMessageDialog(this,"File NOT Found");
    : }
    : jTextArea1.setText(S2);
    :
    :
    : then each line will be stored in S and the whole file will be stored in S2 string. Is that right?????
    :
    : i dont know maybe there is the pblem of differentiating the different parts of eachh record(ex differentiating between the name and ID....)then i should think of transforming the string S into the object Student (for e.g.) ....
    :
    : please any suggestions?? And if am understanding things in a wrong way plz help me and correct me !
    :
    : thanks a lot
    :
    :
    I would use methods in the Student class, which does the reading and writing. For example:
    [code]
    void readFromFile(BufferedReader f) {
    String[] fields = f.readLine().split('/t');
    if (fields.length == numberOfFields) {
    name = fields[0];
    id = Integer.parseInt(fields[1]);
    }
    }

    void writeToFile(BufferedWriter f) {
    String s =
    name + '/t' +
    Integer.toString(id) + '/t' +
    }
    [/code]
    This code uses the tab character to differentiate between the various fields. If tab may be used in one of the fields, then you should use another character, such as the character #1 or #2, since these are not typable.
  • tollitolli Posts: 44Member
    thanks for ur ideas :)

  • tollitolli Posts: 44Member
    hello again...please may u give me ideas aboutn how to implement this thing:


    as explained before the program am doing includes file processing to simulate the student database. i have the student and the crseOffering classes. I need now to allow teachers for example to enter grades and then each student will get a grade per course and eventually we can print out a transcript.


    please give me ideas how to implement it in programming! Do i make grades a part of student's record and courseOFfering records??????? how to print transcripts bla bla bla?? remember am doing it with GUI

    thanksssss

  • zibadianzibadian Posts: 6,349Member
    : hello again...please may u give me ideas aboutn how to implement this thing:
    :
    :
    : as explained before the program am doing includes file processing to simulate the student database. i have the student and the crseOffering classes. I need now to allow teachers for example to enter grades and then each student will get a grade per course and eventually we can print out a transcript.
    :
    :
    : please give me ideas how to implement it in programming! Do i make grades a part of student's record and courseOFfering records??????? how to print transcripts bla bla bla?? remember am doing it with GUI
    :
    : thanksssss
    :
    :
    The best way is to include a hash map in the cource class. This then linkes the student's ID with the student's grade for that course. When you want to see what the student's grades are, you need to loop through all the courses to check if the student's ID is listed for that course and what his grade is.
    Showing the grades can be done using a JTextArea or with a JPanel in a JScrollPane.
    See the PrinterJob class for printing.
  • tollitolli Posts: 44Member
    may u provide ma with a sample code to familiarize me with hashmaps??
Sign In or Register to comment.