In Urgent Need Of Help! Asap!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: In Urgent Need Of Help! Asap!

  1. #1
    Join Date
    Aug 2002
    Posts
    5

    Exclamation In Urgent Need Of Help! Asap!

    i have been given some source codes for which i have to make an application.

    Here is a part of it:

    private void manageAccount()
    {
    Account acc = null;
    int accId;
    int amount;
    int choice;
    accId = KeyboardInput.getInt("Enter Account number: ");
    if (!(myBank.contains(accId)))
    {
    System.out.println("Account "+ accId+" does not exist");
    }
    else // account is found so process it as required
    {
    acc = (Account) myBank.get(accId);
    choice = manageMenu.getMenuChoice();
    while (choice!=0)
    {
    switch (choice) // select required action on the account
    {
    case 1 :
    System.out.println(acc.toString());
    break;
    case 2 :
    amount = KeyboardInput.getIntInRange("Enter Amount: ", 0, 9999);
    acc.deposit(amount);
    System.out.println(acc.toString());
    break;
    case 3 :
    amount = KeyboardInput.getIntInRange("Enter Amount: ", 0, 9999);
    acc.withdraw(amount);
    System.out.println(acc.toString());
    break;
    case 4 :
    if (acc.getClass().getName().equals("CurrentAccount"))
    {
    int newODLimit;
    CurrentAccount currentAcc= (CurrentAccount) acc;
    System.out.println("Overdraft limit is: "+currentAcc.getOverdraftLimit());
    newODLimit = KeyboardInput.getIntInRange("Enter new overdraft limit: ", 0, 9999);
    currentAcc.setOverdraftLimit(newODLimit);
    }
    else


    i have to make an application using these source codes. Howeverr i am not allowed to edit it.
    is there any way i can make an application which can get to these codes?

    for example if the user presses the "Add an Account" button from my application, it will read the code from the AddAccount class.

    or will i need to write out the codes all over again into my new Interface class?

    i know i sound very confused, thats because, well i am.
    i was in hospital for most of my OOp classes and now have to do this resit assignment and there is no one to help! so if anyone can help me please reply! im desperate!!

    p.s , i proberbly havent explaind my situation well so here is the page where my assignment is:

    http://mercury.tvu.ac.uk/oop/oop_ass2r.html

  2. #2
    Join Date
    Aug 2002
    Posts
    5
    My guess would be that they want you to put all the source code, including the file you write with the main method, into a package. That way you will be able to call on the methods that you were given.

    eg.

    package ass2r;

    import java.awt.*;

    public class etc

  3. #3
    Join Date
    Aug 2002
    Posts
    5

    Question

    Thanx for that i was hoping that that was what i am meant to do. However can you suggest how i can go about doing that? I just need a little guide on how to get started.

    For example this is part of a code in a class in the package:

    public void withdraw(int amount)
    {
    if (balance >= amount)
    {
    balance= balance - amount;
    charges= charges + 1;
    }
    }

    so how can i say that if Button "Withraw" is pressed then carry out this method from the ManageAccount class?

    sorry to be a pain again, but any suggestions?
    thankyou

  4. #4
    Join Date
    Jul 2002
    Posts
    60

    Arrow

    Hi Boo,
    When your post came in I did go look at your assmt site; it looks like what your instructor is asking for is to demonstrate your knowledge and understanding of OOP: object oriented programming. This can be the most confusing part of java: private, public, static, final, instantiation, object creation, encapsulation, packages, jars... oh my... it's a mouthful.

    Your assmt is simple, yet the concept is pretty detailed and much too complicated to get into here.

    What the assignment appears to call for is creating new objects from the classes in the package, and then accessing the class methods and properties from the new objects you've created.

    I see that there are class notes on the site link you provided. You might take a quick peek thru them to see if there are examples for this particular topic.

    Creating objects, creating their private and public properties & methods, and then creating programs/classes to utilize, change and access those 'super' parent class qualities, it's all the main part of OOP.

    As a brief example:
    Say you had a parent 'super' class Bike with methods of
    setColor( ) and setType( ).

    For the parent or 'super' class, it creates a Bike object and lets you change the color and model on it. But what if you don't want a Red Tricycle Bike object, and instead you want t



    you could then go and create your own separate class (BoosHomework) to create your own bike object:

    public class BoosHomework{
    public static void main.....{

    Bike booBike = new Bike( ); // create new bike object

    booBike.setColor( ) // call to the Bike superclass method to set color on booBike.

    It's a very interesting concept and I recommend that if you really want to learn Java, that you take your time with it and understand it.

    I realize this doesn't help much, with your assmt due by Monday, but perhaps over the weekend you can take a couple hours and experiment with OOP basics and get an idea of where to go with it.

    Hope this helps!

    ~Jim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center