[Solved] EECS1022 Lab7-Building a Bank App using Android Studio

$25

File Name: EECS1022_Lab7_Building_a_Bank_App_using_Android_Studio.zip
File Size: 508.68 KB

SKU: [Solved] EECS1022 Lab7-Building a Bank App using Android Studio Category: Tag:
5/5 - (1 vote)

1 Task 1: Complete Weekly Java Tutorial Videos

  • For Lab7, you are assigned to study Week 9 Part A1 to Part B4 of the Java tutorial series:
https://www.youtube.com/playlist?list=PL5dxAmCmjv_64z4oGXy0kHBO7_gPkjNmG To reference tutorial videos from the previous weeks, see: [ Week 9 only ]
https://www.youtube.com/playlist?list=PL5dxAmCmjv_6wy2m0yq2wObIWPz4tAxW6 [ All Weeks ]

These Java tutorial videos assigned to you are meant for you to:

  1. Obtain extra hands-on programming experience on Java, supplementing your weekly lectures.
  2. Complete the lab assignment with the necessary skills and background.

Though we do not require the submission of the weekly Java tutorial project (like in Lab0), examples and insights discussed in these tutorials will be covered in your (written and programming) tests and exam: should you decide to skip the weekly tutorial videos, it would be your choice.

As you study through the example Java classes in the tutorial videos, you are advised to type them out (but absolutely feel free to add new Java classes to experiment) on Android Studio.

  • You can find the iPad notes of illustrations from the tutorial videos here:

https://www.eecs.yorku.ca/jackie/teaching/tutorials/notes/EECS1022%20Tutorial%20on%20Java.pdf

Notes from Lab6 and Lab7

  • See this notes on how to manipulate objects with reference-typed, multi-valued attributes:

https://www.eecs.yorku.ca/jackie/teaching/lectures/2021/W/EECS1022/notes/EECS1022_W21_Tracing_ PointCollectorTester.pdf

  • See this notes on how to infer classes and methods from given JUnit tests:

https://www.eecs.yorku.ca/jackie/teaching/lectures/2021/W/EECS1022/notes/EECS1022_W21_Inferring_ Classes_from_JUnit.pdf

W21_Inferring_Classes_from_JUnit_Solution.zip

2 Task 2: Setup an Android Studio Project

Starting Task 2 should mean that you have already completed the weekly Java tutorial videos (Section 1).

2.1 Step 1: Install Android Studio

See the detailed PDF instructions Install Android Studio 3.6.3 File on the M,N,O eClass site: https:// eclass.yorku.ca/eclass/pluginfile.php/2004743/mod_resource/content/2/Installing_Android_Studio_ v3.6.3.pdf.

2.2 Step 2: Set up an Empty Activity in Android Studio

Unlike previous labs, there is no project archive file for you to import. Instead, you are asked to create an Empty Activity in Android Studio:

  1. Launch Android Studio and click on Create New Project.
  2. Under Select a Project Template, select Empty Activity.
  3. Under Configure Your Project:
    • Name: type Bank
    • Package Name: type lab7.bank
    • Save Location: make sure the last part of the path should match the app name Bank
    • Language: choose Java
  4. After the new project is successfully built:
    • Under app/java/eecs1022.lab7.bank, create a new package called model.
  • Under app/java/eecs1022.lab7.bank (test), rename the JUnit test class ExampleUnitTest to Tests.

2.3 Step 3: Download and Replace the Controller Class and JUnit Test Class

  1. From eClass, download the archive file zip, containing:
    • The controller class: java
    • The JUnit test class: java
  2. As shown in the left figure, do the following replacements:
    • Copy and replace the given java to your project folder:

Bank/app/src/main/java/eecs1022/lab7/bank

  • Copy and replace the given java to your project folder: Bank/app/src/test/java/eecs1022/lab7/bank

It is expected that compilation errors exist in both given files when first replaced into your project. See Section 3.2.1.

3 Task 3: Develop a Mobile App in Android Studio

3.1 Step 1: Study the Bank Problem

You are required to develop an object-oriented program solving the problem of a (simplified) bank, which provides services (i.e., deposit, withdraw, transfer, and print statement) to a collection of up to 6 clients (i.e., when a 7th client is attempted to be added to the bank, there should be an error message displayed). Each client can be characterized by their name, numerical balance (always displayed with two digits after the decimal point), and a history (i.e., collection) of up to 10 transactions (for this you can assume that the user will not complete more than 10 transactions for each client). Each client should be identified by their name. We may want to perform one of the following kinds of transactions:

  • Deposit some input amount of money to a clients account (identified by their name).
  • Withdraw some input amount of money from a clients account (identified by their name).
  • Transfer some input amount of money from a clients account to another clients account (identified by their names). In the case of transferring $amount from client c1 to client c2, it should be considered as two separate transactions: a withdrawal of $amount from client c1 and a deposit of $amount to client c

Also, throughout the life time of a bank object, given a clients name, we may want to it return a statement summarizing the clients status (i.e., account balance) and their history list of transactions.

3.2 Step 2: Using JUnit Tests to Develop Classes in Model Package

3.2.1 Inferring Model Classes from JUnit Tests

  • It is expected that the Tests JUnit class (which you downloaded and copied from eClass) contains compilation errors. This is because that declarations and definitions of the required class(es) and method(s) it references are missing.
  • The model package you created is empty. Class(es) and method(s) derived from the given JUnit class must be added to this package. You must not create any classes not indicated by the JUnit tests, otherwise your submitted model classes will not compile with the grading program.

Therefore, your tasks are:

  1. Inferring from the given JUnit tests, add the missing class(es) and method(s) into the model Note a line from the Tests class (which specifies that all classes from the model package are referenced):

import eecs1022.lab7.bank.model.*;

  1. Pass all JUnit tests given to you (i.e., a green bar).

You must not modify these given JUnit tests, as they suggest how the intended class(es) and method(s) should be declared.

How to Deal with a Failed JUnit Test? Like the previous labs, in Android Studio, place breakpoints around assertions of the failed tests, launch the debugger, and then use the step over, step into, step out, Variables, and Watches tools to help fix your code. See Java Tutorials Week 9 for how to use all these.

3.2.2 Status of Bank

A banks status reports whether or not the last invoked service (i.e., add a new account, deposit, withdraw, transfer, or print statement) results in an error:

  • When there is an error upon invoking the service, the banks status should be the corresponding error message.
  • Otherwise, when there is no error upon invoking the service, the banks status should be a summary of each stored accounts status (see the given JUnit tests).

When multiple errors occur simultaneously, exactly one message for the lowest-ranked error is displayed. For example, say the number of clients has not reached the maximum yet, then given a clashing name (an error with rank 2) and a non-positive initial balance (an error with rank 3), we only output the error message Error: Client n already exists.

Add a New Account

Inputs: Name of client (say n) and the Initial Balance of client (say bal)

Rank Error Condition Error Message
2 n n
3 bal is non-positive (i.e., 0) Error: Non-Positive Initial Balance

Confirm: Case of a DEPOSIT Transaction

Inputs: DEPOSIT chosen as the service type, name of to-account (say toName), and amount of transaction (say amount).

Rank Error Condition Error Message
1 toName is not an existing clients name Error: To-Account toName does not exist
2 amount is non-positive (i.e., 0) Error: Non-Positive Amount

Confirm: Case of a WITHDRAW Transaction

Inputs: WITHDRAW chosen as the service type, name of from-account (say fromName), and amount of transaction (say amount).

Rank Error Condition Error Message
1 fromName is not an existing clients name Error: From-Account fromName does not exist
2 amount is non-positive (i.e., 0) Error: Non-Positive Amount
3 amount is larger than from-accounts balance Error: Amount too large to withdraw

Confirm: Case of a TRANSFER Transaction

Inputs: TRANSFER chosen as the service type, name of from-account (say fromName), name of to-account (say toName), and amount of transaction (say amount).

Rank Error Condition Error Message
2 toName
3 amount 0)
4 amount is larger than from-accounts balance Error: Amount too large to transfer

Confirm: Case of a Print Statement Service

Inputs: Name of a client (say n)

Error Condition Error Message
n is not an existing clients name Error: From-Account n does not exist

3.2.3 Hints and Requirements

  • See this notes on how to declare and manipulate reference-typed, multi-valued attributes:

https://www.eecs.yorku.ca/jackie/teaching/lectures/2021/W/EECS1022/notes/EECS1022_W21_Tracing_ PointCollectorTester.pdf

  • See this notes on how to infer classes and methods from given JUnit tests:

https://www.eecs.yorku.ca/jackie/teaching/lectures/2021/W/EECS1022/notes/EECS1022_Inferring_ Classes_and_Methods_from_JUnit_Tests.pdf

Programming IDEs such as Eclipse and Android Studio are able to fix such compilation errors for you. However, you are advised to follow the guidance as specified in the notes to fix these compilation errors manually, because: 1) it helps you better understand how the intended classes and methods work together; and 2) you may be tested in a written test or exam without the assistance of IDEs.

  • Any new class(es) you add must reside in the model
    • Once the necessary class(es) and method(s) are declared, you can add as many attributes as necessary to implement the body of each method.
    • Study carefully example instances as specified in java: they suggest the how the intended class(es) and method(s) should be declared and implemented.
    • Focus on gradually passing one test at a time.

3.3 Step 3: Design a GUI Layout

3.3.1 Given GUI Layout to Implement

You are then asked to implement the following GUI design:

In the left GUI design:

  • Textviews (for displaying input prompts) are boxed in green.
  • Plain Texts (or textfields for reading user-typed inputs) are boxed in blue.
  • The spinner (for displaying a drop-down menu of options) is boxed in orange.
  • Buttons (for invoking attached controller methods) are boxed in red.
  • The (invisible) textview (for displaying computation results) is boxed in purple.

To implement the above GUI design, open activitymain.xml (under app/src/main/res/layout) in Android Studio.

Then, drag, drop, and organize the above specified GUI components. For each GUI component, be sure to set the appropriate text, as suggested above, and set its id to be used later in the controller (MainActivity.java).

3.3.2 Assumed Usage Pattern of the App

For the simplicity of this lab, you can assume that users (or testers) of your app behave in the following way:

Adding a New Account

1.

1.1 Enter the name of a new client.

1.2 Enter the initial balance of this new client.

1.3 Click on the button ADD A NEW ACCOUNT

This step should cause your program to create a Client object, and add it to the Bank objects array attribute clients.

See Section 3.2.2 for the possible error messages to be displayed.

Completing a New Transaction

2.

2.1 Select a service type (i.e., DEPOSIT, WITHDRAW, TRANSFER).

2.2 Enter the To and/or From account owners:

  • In the case of deposit, input on the To-Account textfield should be retrieved; any input on the From-Account textfield should be ignored.
  • In the case of withdraw, input on the From-Account textfield should be retrieved; any input on the To-Account textfield should be ignored.
    • Enter the amount for the selected service type.
    • Click on the CONFIRM button.

In cases of DEPOSIT and WITHDRAW, this step should cause your program to add a new transaction to, respectively, the to-account and the from-account. In the case of TRANSFER, a withdraw transaction should be added to the from-account, and a deposit transaction should be added to the to-account.

See Section 3.2.2 for the possible error messages to be displayed.

Printing the Statement

3.

  • Select the service type (i.e., Print Statement).
  • Input on the From-Account textfield should be retrieved; any input on the To-Account textfield should be ignored.
  • Click on the CONFIRM button.

See Section 3.2.2 for the possible error messages to be displayed.

The two buttons ADD A NEW ACCOUNT and CONFIRM may be clicked in any order.

3.4 Step 4: Develop the Controller Class

From Section 2.3, you already copied and replaced the given controller class MainActivity.

  • Follow through the comments/hints in the given controller file to complete it.
  • Refer to this short demo tutorial video on how your Android mobile app is supposed to work: https:

//www.youtube.com/watch?v=xal9NkIs46U&list=PL5dxAmCmjv_7YgI2LgcwjWTHiNZSR-aQX&index=2

  • Test the app by launching it using an emulator in Android Studio:
  • The app name on the top of the emulator screen must read:

Bank App FirstName LastName (StudentNumber)

where your first name, last name, and student number are displayed in the suggested order.

Hint: Go to the resource file app/res/values/strings.xml and modify the appname attribute accordingly.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] EECS1022 Lab7-Building a Bank App using Android Studio[Solved] EECS1022 Lab7-Building a Bank App using Android Studio
$25