public void creditaccount(string accountnumber, float amount) { this.accounts.get(accountnumber).credit(amount); }



Similar documents
Java: overview by example

3 Pillars of Object-oriented Programming. Industrial Programming Systems Programming & Scripting. Extending the Example.

Inheritance, overloading and overriding

D06 PROGRAMMING with JAVA. Ch3 Implementing Classes

Lecture J - Exceptions

>

More on Objects and Classes

Introduction to Java

Section 6 Spring 2013

D06 PROGRAMMING with JAVA

Introduction to Object-Oriented Programming

AP Computer Science Static Methods, Strings, User Input

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

COSC Introduction to Computer Science I Section A, Summer Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19

Programming by Contract. Programming by Contract: Motivation. Programming by Contract: Preconditions and Postconditions

Collections.sort(population); // Método de ordenamiento

2009 Tutorial (DB4O and Visual Studio 2008 Express)

Unit Testing & JUnit

You are to simulate the process by making a record of the balls chosen, in the sequence in which they are chosen. Typical output for a run would be:

DHBW Karlsruhe, Vorlesung Programmieren, Remote Musterlösungen

I. INTRODUCTION. International Journal of Computer Science Trends and Technology (IJCST) Volume 3 Issue 2, Mar-Apr 2015

System.out.println("\nEnter Product Number 1-5 (0 to stop and view summary) :

CompSci 125 Lecture 08. Chapter 5: Conditional Statements Chapter 4: return Statement

Licensed for viewing only. Printing is prohibited. For hard copies, please purchase from

Sample CSE8A midterm Multiple Choice (circle one)

- ' +. /0 ( 1 +. ' &+. /"0 &1,

Chapter 20 Streams and Binary Input/Output. Big Java Early Objects by Cay Horstmann Copyright 2014 by John Wiley & Sons. All rights reserved.

ForeverSOA: Towards the Maintenance of Service-Oriented Architecture (SOA) Software

Consuming a Web Service(SOAP and RESTful) in Java. Cheat Sheet For Consuming Services in Java

Object-Oriented Programming in Java

Chapter 13 - Inheritance

D06 PROGRAMMING with JAVA

LAB4 Making Classes and Objects

Chapter 2 Introduction to Java programming

Topic 11 Scanner object, conditional execution

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75

Java 進 階 程 式 設 計 03/14~03/21

The following program is aiming to extract from a simple text file an analysis of the content such as:

API Document Webaroo Technology India Pvt. Ltd.

Arrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays:

See the Developer s Getting Started Guide for an introduction to My Docs Online Secure File Delivery and how to use it programmatically.

File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10)

ICOM 4015: Advanced Programming

B.Sc (Honours) - Software Development

Example of a Java program

Install Java Development Kit (JDK) 1.8

1001ICT Introduction To Programming Lecture Notes

1. Writing Simple Classes:

MR-(Mapreduce Programming Language)

J a v a Quiz (Unit 3, Test 0 Practice)

Zebra and MapReduce. Table of contents. 1 Overview Hadoop MapReduce APIs Zebra MapReduce APIs Zebra MapReduce Examples...

CS193j, Stanford Handout #10 OOP 3

Intruduction to Groovy & Grails programming languages beyond Java

JAVA - EXCEPTIONS. An exception can occur for many different reasons, below given are some scenarios where exception occurs.

Building Java Programs

Basics of Java Programming Input and the Scanner class

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius

Java Program Coding Standards Programming for Information Technology

Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.

Massachusetts Institute of Technology 6.005: Elements of Software Construction Fall 2011 Quiz 2 November 21, 2011 SOLUTIONS.

Hello World RESTful web service tutorial

Overview of Web Services API

Arrays in Java. Working with Arrays

Hibernate Language Binding Guide For The Connection Cloud Using Java Persistence API (JAP)

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Building Java Programs

Introduction to Computer Programming, Spring Term 2014 Practice Assignment 3 Discussion

LAB 1. Familiarization of Rational Rose Environment And UML for small Java Application Development

JAVA Program For Processing SMS Messages

Ready, Set, Go Getting started with Tuscany

C:\Documents and Settings\Gijs\Desktop\src\client\Client.java dinsdag 3 november :50

Part I. Multiple Choice Questions (2 points each):

JAVA ARRAY EXAMPLE PDF

1.00/ Session 2 Fall Basic Java Data Types, Control Structures. Java Data Types. 8 primitive or built-in data types

D06 PROGRAMMING with JAVA

5. Advanced Object-Oriented Programming Language-Oriented Programming

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

SOAP RPC. SimpleObjectAccessProtocol. RemoteProcedureCall mittels XML über Port 80. Sascha Sadikni BPS Präsentation

Using ilove SharePoint Web Services Workflow Action

Lab 5: Bank Account. Defining objects & classes

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Object Oriented Software Design

1 Hour, Closed Notes, Browser open to Java API docs is OK

Creating a Simple, Multithreaded Chat System with Java

Evaluation. Copy. Evaluation Copy. Chapter 7: Using JDBC with Spring. 1) A Simpler Approach ) The JdbcTemplate. Class...

D06 PROGRAMMING with JAVA

Software Development with UML and Java 2 SDJ I2, Spring 2010

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum

WHAT ARE PACKAGES? A package is a collection of related classes. This is similar to the notion that a class is a collection of related methods.

Introduction to Java Lecture Notes. Ryan Dougherty

Design Patterns. Firuza Aibara. 11 August IIT Bombay (CSE) Firuza Aibara (IIT Bombay (CSE)) Design Patterns 11 August / 16

IBM WebSphere Application Server

AP Computer Science File Input with Scanner

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

public static void main(string[] args) { System.out.println("hello, world"); } }

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Software Engineering 1 EEL5881 Spring Homework - 2

Moving from CS 61A Scheme to CS 61B Java

Remote Method Invocation

INTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 7: Object-Oriented Programming. Introduction

Transcription:

package bank; //... public class Bank { private Map<String, BankAccount> accounts; public Bank() { this.accounts = new HashMap<String,BankAccount>(); public void addaccount(bankaccount account) { this.accounts.put(account.getnumber(), account); public void displaybalance(string accountnumber) { float value = this.accounts.get(accountnumber).getbalance(); System.out.println("balance of account n "+accountnumber+" : "+value); public void creditaccount(string accountnumber, float amount) { this.accounts.get(accountnumber).credit(amount); public void withdraw(string accountnumber, float amount) { this.accounts.get(accountnumber).withdraw(amount); // and other methods handling BankAccount... public static void main(string[] args) { Bank bank = new Bank(); bank.addaccount(new ProtectedBankAccount(new Person(),"number1",0)); bank.addaccount(new BonusBankAccount(new Person(),"number2",0.01f)); bank.creditaccount("number1", 1000); bank.creditaccount("number2", 500); bank.displaybalance("number2"); bank.withdraw("number1",444);

import java.util.date; import java.util.list; public interface BankAccount { public Person getowner(); public String getnumber(); public float getbalance(); public void credit(float amount); public void withdraw(float amount); public List<Operation> getoperationsafter(date time);

public class StandardBankAccount implements BankAccount { public StandardBankAccount(Person owner, String number) {

public class ProtectedBankAccount implements BankAccount { private float lowerbound; public ProtectedBankAccount(Person owner, String number, float lowerbound){ this.lowerbound = lowerbound; if (this.balance-amount >= this.lowerbound) { // else nothing... or an exception to be thrown public float getlowerbound() { return this.lowerbound;

public class BonusBankAccount implements BankAccount { private float bonusrate; public BonusBankAccount(Person owner, String number, float bonusrate) { this.bonusrate = bonusrate; this.balance = this.balance + (amount*this.bonusrate); public float getbonusrate() { return this.bonusrate;

public class *****BankAccount implements BankAccount { public *****BankAccount(Person owner, String number *****) {