Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
plz this : need help Posted by tolli on 10 Mar 2007 at 12:13 PM
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
Report
Re: plz this : need help Posted by zibadian on 10 Mar 2007 at 12:51 PM
: 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:
  student.name = nameField.getText();
  student.birthDay = birthDayField.getText();
  String s = studentIDField.getText().Trim();
  if (s != "") student.id = Integer.parseInt(s);

The same can be done for other records.
Report
Re: plz this : need help Posted by tolli on 10 Mar 2007 at 3:04 PM
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+"\t\t";
if (i%3==0)
S2+="\n";
}
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

Report
Re: plz this : need help Posted by zibadian on 10 Mar 2007 at 9:50 PM
: 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+"\t\t";
: if (i%3==0)
: S2+="\n";
: }
: 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:
  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' +
  }

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.
Report
Re: plz this : need help Posted by tolli on 11 Mar 2007 at 1:27 AM
thanks for ur ideas :)

Report
agian Posted by tolli on 11 Mar 2007 at 1:57 AM
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

Report
Re: agian Posted by zibadian on 11 Mar 2007 at 2:06 AM
: 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.
Report
Re: agian Posted by tolli on 11 Mar 2007 at 2:24 AM
may u provide ma with a sample code to familiarize me with hashmaps??



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.