Hej mam takie zadanie
Zaimplementuj klasę Student, do przechowywania imienia, nazwiska, numer indeksu i obecność (wyrażonej w procentach) oceny z POJ (typu int). Jeżeli podczas tworzenia obiektu nie zostało przekazane imię i nazwisko, pola powinny być ustawione wartością "Unknown". Dodaj odpowiednie metody set i get do wszystkich pól klasy. Jeżeli obecnocność jest mniejsza niż 50%, student powinien otrzymać ocenę 2. Przetestuj program, tworząc trzy różne obiekty klasy Student
.
Na ten moment stworzyłam plik Student.java
public class Student {
private String imie;
private String nazwisko;
private String nrindex;
private int obecnosc;
private int oceny;
public Student(String imie, String nazwisko, String nrindex, int obecnosc, int oceny) {
this.imie = imie;
this.nazwisko = nazwisko;
this.nrindex = nrindex;
this.obecnosc = obecnosc;
this.oceny = oceny;
}
public String getImie() {
return imie;
}
public void setImie(String imie) {
this.imie = imie;
}
public String getNazwisko() {
return nazwisko;
}
public void setNazwisko(String nazwisko) {
this.nazwisko = nazwisko;
}
public String getNrindex() {
return nrindex;
}
public void setNrindex(String nrindex) {
this.nrindex = nrindex;
}
public int getObecnosc() {
return obecnosc;
}
public void setObecnosc(int obecnosc) {
this.obecnosc = obecnosc;
}
public int getOceny() {
return oceny;
}
public void setOceny(int oceny) {
this.oceny = oceny;
}
}
i plik StudentMain.java
import java.util.Scanner;
public class StudentMain {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a, b, c, d, e;
Student.setImie(a);
Student.setNazwisko(b);
Student.setNrindex(c);
Student.setObecnosc(d);
Student.setOceny(e)
System.out.println("Podaj imię: ");
a = scan.nextInt();
System.out.println("Podaj nazwisko: ");
b = scan.nextInt();
System.out.println("Podaj Numer indeksu: ");
c = scan.nextInt();
System.out.println("Podaj obecność w %: ");
d = scan.nextInt();
if(d > 50) {
System.out.println("Podaj swoją ocenę: ");
e = scan.nextInt();
}else{
e == 2}
System.out.println(a); //wersja robocza wypisania wyników
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println(e);
}
}
Moim głównym problemem jest to, że nie wiem jak w pliku StudentMain pobrać dane które zostaną przypisane do konkretnych pól klasy.