bonjour,
je fais un programme de gestion de dossier en grande ecole.
Je travail avec DRJAVA qui est amplement suffisant pour les algorithmes de base.

je rencontre un probleme avec mon constructeur de classe, au niveau de l'affectation des variables.

voici un peu de code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 
import java.lang.String;
import java.util.Scanner;
 
 
public class DossierCandidatureGER{
  // Ici des attributs
  String nom_cdt;
  String numero_cdt;
  boolean emarge;
  boolean epreuve_ecrit;
  int note_ecrit;
  int note_orale;
  boolean epreuve_orale;
  boolean absence;
  boolean admit;
 
  // constructeur
  public DossierCandidatureGER(String nom, String numero){
    nom =nom_cdt; // ici quelque chose ne va pas
    numero = numero_cdt; // ici quelque chose ne va pas
    emarge=false;
    epreuve_ecrit = false;
    note_ecrit = 0;
    note_orale = 0;
    epreuve_orale = false;
    absence = true;
    admit = false;
 
  }
 public void enregistrerNoteEpreuveEcrite(int note){
        Scanner sc = new Scanner(System.in); // creation d'un objet scanner
     note_ecrit = sc.nextInt(); // lecture d'
 
 
  }
  public void publierResultatEcrit(){
    note_ecrit =note_ecrit;
 
  }
  public void enregistrerNoteEpreuveOrale(int note){
       Scanner sc = new Scanner(System.in); // creation d'un objet scanner
     note_orale = sc.nextInt(); // lecture d'
     note = note_orale;
  }
// Les méthodes statiques ...
 
// le programme principal
 
  public static void main(String[] args){
   DossierCandidatureGER exam_ger = new DossierCandidatureGER("nom", "numero");
   exam_ger.enreg_cdt();
   exam_ger.enregistrerNoteEpreuveEcrite(note_ecrit); // le compilateur s'arrête ici
   exam_ger.publierResultatEcrit();
   exam_ger.enregistrerEmargementEpreuveEcrite();
   exam_ger.enregistrerAbsenceALOral();
   exam_ger.enregistrerNoteEpreuveOrale(note_orale);
   exam_ger.publierResultatFinal();
   System.out.println(exam_ger.toString());
 
  }

erreur
2 errors found:
File: /home/phipo/fun-mooc-java-obj/DossierCandidatureGER.java [line: 80]
Error: non-static variable note_ecrit cannot be referenced from a static context
File: /home/phipo/fun-mooc-java-obj/DossierCandidatureGER.java [line: 84]
Error: non-static variable note_orale cannot be referenced from a static context