Exemple #1
0
 public void connectPortController(Class<jmri.jmrix.AbstractStreamPortController> T) {
   try {
     java.lang.reflect.Constructor<?> ctor =
         T.getConstructor(
             java.io.DataInputStream.class, java.io.DataOutputStream.class, String.class);
     connectedController =
         (jmri.jmrix.AbstractStreamPortController)
             ctor.newInstance(
                 getIOStream().getInputStream(),
                 getIOStream().getOutputStream(),
                 "XBee Node " + getPreferedName());
     connectedController.configure();
   } catch (java.lang.InstantiationException ie) {
     log.error("Unable to construct Stream Port Controller for node.");
     ie.printStackTrace();
   } catch (java.lang.NoSuchMethodException nsm) {
     log.error("Unable to construct Stream Port Controller for node.");
     nsm.printStackTrace();
   } catch (java.lang.IllegalAccessException iae) {
     log.error("Unable to construct Stream Port Controller for node.");
     iae.printStackTrace();
   } catch (java.lang.reflect.InvocationTargetException ite) {
     log.error("Unable to construct Stream Port Controller for node.");
     ite.printStackTrace();
   }
 }
  @Override
  public void onListItemClick(ListView l, View v, int position, long id) {
    ReadMeetingFragment rrf = new ReadMeetingFragment();
    Bundle b = new Bundle();
    b.putSerializable("frag", ReadMeetingFragment.class);
    b.putInt("Position", position);
    MainActivity a = (MainActivity) getActivity();
    try {
      ((MainActivity) getActivity()).changeFragments(b, null);
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (java.lang.InstantiationException e) {
      e.printStackTrace();
    }

    // TODO: ADD THE FRAGMENT WITH THE HOMEWORK DETAILS
  }
  @Override
  public void onQRCodeRead(String text, PointF[] points) {
    // TODO Auto-generated method stub
    String from = null;
    try {
      from = getArguments().getString("from");
    } catch (Exception e) {
      // TODO: handle exception
    }
    Class<?> clazz;
    Object object = null;
    try {
      clazz = Class.forName("info.androidhive.slidingmenu." + from);
      object = clazz.newInstance();
      System.out.println(object.toString());
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IllegalArgumentException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (java.lang.InstantiationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    Bundle args = new Bundle();
    args.putString("barkod", text);
    ((Fragment) object).setArguments(args);
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.replace(R.id.frame_container, (Fragment) object, "Anasayfa");
    fragmentTransaction.addToBackStack(null);
    fragmentTransaction.commit();
  }
Exemple #4
0
  public Atm() // constructor
        // sets the customer array to that found in the file if the file exists
      {
    try {
      // Set cross-platform Java L&F (also called "Metal")
      UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (UnsupportedLookAndFeelException e) {
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (InstantiationException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    }

    if (logFile.exists()) {
      try {
        adminLogs = returnLog("p2.log");
        if (!adminLogs.isEmpty()) {
          // there may be customer data but perhaps no transactions yet.
          ArrayList<Integer> allTransactions = new ArrayList<>(100);
          for (AdminLog a : adminLogs) {

            int transaction = a.getTransactionID();
            ;
            allTransactions.add(transaction);
          }
          transaction_counter = Collections.max(allTransactions) + 1;
        }
      } catch (ClassNotFoundException | IOException e) {
        e.printStackTrace();
      }
    }

    if (DBfile.exists()) {
      try {

        cust = returnSavedData("p2.dat");

        // sets the starting ID to the max of all the IDs stored in the file.
        allIDs = new ArrayList<Integer>(100);
        ArrayList<Integer> allAccounts = new ArrayList<>();
        for (Customer customer : cust) {
          String idString = customer.returnID();
          int id = Integer.parseInt(idString);
          allIDs.add(id);
          int accountNumber = customer.returnMaxAccount();
          allAccounts.add(accountNumber);
        }
        // checks to see if the customer has even made any accounts, if not, max accounts will be
        // set at 1001
        if (starting_account_number != 1) {
          starting_account_number = Collections.max(allAccounts) + 1;
        }
        starting_customer_number = Collections.max(allIDs) + 1;

      } catch (ClassNotFoundException | IOException e) {
        e.printStackTrace();
      }
    } else {
      cust = new ArrayList<>(100);
      // creates the file if it does not exist
      try {
        saveFile(cust, DBfile);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    interest_rate = 5;
  }