Contenu connexe
Similaire à résumé POO java .pdf
Similaire à résumé POO java .pdf (19)
résumé POO java .pdf
- 1. Niema ALAOUI MDAGHRI GL1 A
POO java résumé
Composition et Association Héritage
public class C1 {
private int A ;
C1(){}
void ToString () {}
public int getA() {return A ;} //composition
}
public class C2 {
private C1 C ; //association
C2(){ C.getA() ;}
void ToString () {}
}
public class C1 {
protected int A ;
C1(){}
void ToString () {}
}
public class C2 extends C1 {
final int B ; //B ne peut plus être héritée
C2(){ super() ;}
void ToString () { super.ToString() ;}
}
Classe Abstract Interface
public abstract class C1 {
static int A ;
static void ToString () {}
static int getA() {return A ;}
}
public interface C1 {
void Meth1 () ;
int Meth2 (int A) ;
}
public class C1 implements C1 {
@Override
void Meth1 () {}
int Meth2 (int A) {return 0 ;}
}
Tableau Vector
import java.util.Arrays ;
import java.util.Scanner ;
public class Tableau {
int T[],T2[];
int i ;
Scanner sc= new Scanner(System.in) ;
Tableau (){
T = new int[10] ; T2 = new int[10] ;
i=0 ;
}
void Remplir () {
for(i=0 ;i<10 ;i++){
T[i]=sc.nextInt() ; T2[i]=T[i] ;
}}
void moyenne() {
double moy, moy2 ;
for(i=0 ;i<10 ;i++){
moy=((double) T[i] + moy) ;
}
moy2=moy/10 ;
}
void Trier () { Arrays.sort(T) ;}
void PlusGrand () {
int g=0 ;
i=0 ;
Arrays.sort(T2) ;
for(i=0 ;i<=9 ;i++){ g=T2[i] ; }
}
void PlusPetit () {
int p=0 ;
i=0 ;
Arrays.sort(T2) ;
for(i=9 ;i<=0 ;i--){ g=T2[i] ; }
}
void Affiche () {
for(i=0 ;i<10 ;i++){
System.out.printf(T[i]) ;
}}
}
import java.util.Vector ;
import java.util.Scanner ;
public class collection {
Vector <Type> v ;
Scanner sc= new Scanner(System.in) ;
collection (){ v= new Vector<Type>() ;}
void Remplir () {
Type1 T1 ;
Type2 T2 ;
int choix=5 ;
while (choix != 0){
choix = sc.nextInt() ;
switch (choix){
case 1 : T1 = new Type1() ;v.add(T1) ;break ;
case 2 : T2 = new Type2() ;v.add(T2) ;break ;
}}}
void Remplir2 (int Taille) {
Type T ;
for(int i=v.size() ;i<Taille ;i++){
T= new Type() ; v.add(T) ;
}}
void PlusGrand () {
Type T=null ;
int perm = 0 ;
while (perm = 0){
for(Type T1 : v){
for(Type T2 : v){
if ( T1.get() < T2.get() ) {
T=T2 ; perm+=1 ;
}}}
}
void Rechercher () {
if (v.contains(T)) return(true) ;
else return(false) ;
}
void Affiche () {
for(Type T : v) T.affiche() ;
}
}