Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // radio niske :p
- class Student {
- String ime;
- String prezime;
- int godine;
- public Student(String ime, String prezime, int godine){
- this.ime = ime;
- this.prezime = prezime;
- this.godine = godine;
- }
- public String toString() {
- return ime + " " + prezime + " " + godine;
- }
- }
- class NizStudenata {
- static final int MAX_BR = 100;
- Student[] spisak;
- int br;
- public NizStudenata() {
- spisak = new Student[MAX_BR];
- br = 0;
- }
- public void ucitajIzFajla(String fajl) {
- if (Svetovid.testIn(fajl))
- {
- while (Svetovid.in(fajl).hasMore())
- {
- spisak[br] = new Student(Svetovid.in(fajl).readToken(), Svetovid.in(fajl).readToken(), Svetovid.in(fajl).readInt());
- br++;
- }
- }
- Svetovid.in(fajl).close();
- }
- public void unesiNovog(String fajl) {
- String ime = Svetovid.in.readToken();
- String prezime = Svetovid.in.readToken();
- int godine = Svetovid.in.readInt();
- spisak[br] = new Student(ime, prezime, godine);
- Svetovid.append(fajl).println(spisak[br]);
- br++;
- Svetovid.in(fajl).close();
- }
- }
- public class JakiStudenti {
- static NizStudenata spisak = null;
- public static void main (String[] args) {
- NizStudenata spisak = new NizStudenata();
- spisak.unesiNovog("studenti.txt");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement