Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

AP Computer Science/Object-Oriented Programming

From Wikibooks, open books for an open world
<AP Computer Science

The basic task of object-oriented programming is to connect the data with the methods that can operate on that data. Before the introduction of Object-Oriented Programming, many other types of paradigms were used such as procedural programming. While object-oriented programming can be used to describe a procedural process, it is more powerful than the traditional procedural programming paradigm.

The AP Computer Science exam makes use of the Java programming language, which is a class-based object-oriented language. In this module we will introduce the main topics of object-oriented design.

Objects

[edit |edit source]

The basic object is a collection of data and the methods that can be used with them. We will abstract away the actual implementation of the classes and instead will present only diagrams.

The diagram presented here represents a bank account. The bank account does not need to be described in all detail, we only need to know the amount of money that is currently in the account and how to identify the account. The operations that can be used on the bank account are create, deposit, withdraw, and close. We do not allow the client to withdraw a dollar and cents; they can only withdraw an integral value.

The object presented here would be translated into Java as the following:

publicclassAccount{Integerbalance=0;StringaccountIdenitifier;publicAccount(Integerbalance,StringaccountIdentifier){..}publicvoiddeposit(Integeramount){..}publicbooleanwithdraw(Integeramount){..}publicIntegerclose(){..}}
Retrieved from "https://en.wikibooks.org/w/index.php?title=AP_Computer_Science/Object-Oriented_Programming&oldid=4051503"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp