From: Jérôme Benoit Date: Tue, 3 Apr 2018 14:16:34 +0000 (+0200) Subject: exo3: Add the first part code. X-Git-Url: https://git.piment-noir.org/?p=Project_POO.git;a=commitdiff_plain;h=fe98f4bdb1c499bfe6ef05b9afdb26d1be3cb4fa exo3: Add the first part code. Signed-off-by: Jérôme Benoit --- diff --git a/exo3/Main.java b/exo3/Main.java index 41749bf..f15a4ec 100644 --- a/exo3/Main.java +++ b/exo3/Main.java @@ -1,3 +1,5 @@ +import java.lang.reflect.Field; +import java.lang.reflect.Method; class Main { @@ -39,6 +41,26 @@ class Main { * @param String[] args main() function arguments array */ public static void main(String[] args) { - main_orig(args); + String className = args[0]; + Class cl = null; + try { + cl = Class.forName(className); + } + catch (ClassNotFoundException e) { + System.out.println("Entered class name do not exist."); + System.exit(-1); + } + + Field[] fields = cl.getFields(); + Method[] methods = cl.getMethods(); + + for (int i = 0; i < fields.length; i++) { + System.out.println(fields[i]); + } + + for (int i = 0; i < methods.length; i++) { + System.out.println(methods[i]); + } + } }