The fourth weekly summary and the second experiment


Experiment two  Java Simple Classes and Objects

  • Purpose
  • Master class definitions, familiar with the role attribute, constructors, methods, and declare variables to grasp the type of the return value of the method as classes used;
  • We understood that the difference between classes and objects, master the use of constructor methods familiar and attribute instances referenced by object name;
  • Understand static modification on pay class, class member variables and class methods.
  • Content Experiments
  1. Write a rectangle representing a class named Rectangle. Attributes which includes a wide width, height, and color of high color, width and height are double-type, and the color is of type String. Requirements class has:

(1) using the constructor completes the initial assignment of each attribute

(2) using the get ... () and set ... () in the form of complete access and modify the properties of

(3) calculate the area of ​​providing getArea () method and the calculated circumference getLength () method

  1. Unique identification (a combination of characters and numbers 11 lengths) bank account records Account have an account, user name, date of opening the account password, the current balance (six-digit number that can be used at the beginning 0). Bank of when to open a new account, the bank provides an identifier, the initial account password 123456, customers provide your name, customers can open an account when a deposit for an initial account amount, without providing an initial balance of zero. Definition of the class and ask the class provides the following methods: deposits, withdrawals, change your password, you can query separately identifies an account, name, date of opening, the current balance and other information.

 

Guess you like

Origin www.cnblogs.com/songjiah/p/11536134.html