Презентация Java 4 WEB. Lesson 3 - OOP онлайн

На нашем сайте вы можете скачать и просмотреть онлайн доклад-презентацию на тему Java 4 WEB. Lesson 3 - OOP абсолютно бесплатно. Урок-презентация на эту тему содержит всего 46 слайдов. Все материалы созданы в программе PowerPoint и имеют формат ppt или же pptx. Материалы и темы для презентаций взяты из открытых источников и загружены их авторами, за качество и достоверность информации в них администрация сайта не отвечает, все права принадлежат их создателям. Если вы нашли то, что искали, отблагодарите авторов - поделитесь ссылкой в социальных сетях, а наш сайт добавьте в закладки.



Оцените!
Оцените презентацию от 1 до 5 баллов!
  • Тип файла:
    ppt / pptx (powerpoint)
  • Всего слайдов:
    46 слайдов
  • Для класса:
    1,2,3,4,5,6,7,8,9,10,11
  • Размер файла:
    644.24 kB
  • Просмотров:
    102
  • Скачиваний:
    0
  • Автор:
    неизвестен



Слайды и текст к этой презентации:

№1 слайд
Java WEB Lesson - OOP
Содержание слайда: Java 4 WEB Lesson 3 - OOP

№2 слайд
Lesson goals Class design
Содержание слайда: Lesson goals Class design Implement encapsulation Implement inheritance including visibility modifiers and composition Implement polymorphism

№3 слайд
Object vs Class
Содержание слайда: Object vs Class

№4 слайд
Abstract Classes May contain
Содержание слайда: Abstract Classes May contain any number of methods including zero If class has at least one abstract method – class is abstract abstract void clean() Abstract methods may not appear in a class that is not abstract The first concrete subclass of an abstract class is required to implement all abstract methods that were not implemented by a superclass

№5 слайд
Method vs Constructor Method
Содержание слайда: Method vs Constructor Method describes behavior Method signature: - name - arguments (including order) Specific method with the same to class name and without return statement called Constructor

№6 слайд
Constructor class Animal
Содержание слайда: Constructor class Animal { String name; Animal() { this("No-Name"); } public Animal(String name) { this.name = name; } } class Main{ public static void main(String[] args) { println(new Monkey()); println(new Monkey(2)); } }

№7 слайд
Overloading and Overriding
Содержание слайда: Overloading and Overriding class Game { void play() { // move to the left } }

№8 слайд
Overriding rules The access
Содержание слайда: Overriding rules The access modifier must be the same or more accessible; The return type must be the same or a more restrictive type, also known as covariant return types; If any checked exceptions are thrown, only the same exceptions or subclasses of those exceptions are allowed to be thrown; The methods must not be static. (If they are, the method is hidden and not overridden); @Override - It is a great idea to get in the habit of using it in order to avoid accidentally overloading a method.

№9 слайд
Overloading precedence Exact
Содержание слайда: Overloading precedence Exact match by type Matching a superclass type Converting to a larger primitive type Converting to an autoboxed type Varargs

№10 слайд
Overloading precedence class
Содержание слайда: Overloading precedence class Overloading { static void overloadedMethod(int i) { // will enter if nothing is commented System.out.println("in int"); } static void overloadedMethod(long i) { // will enter if comment 'int' System.out.println("in long"); } static void overloadedMethod(Integer i) { // will enter if comment 'int' and 'long' System.out.println("in Integer"); } static void overloadedMethod(Number i) { // will enter if comment 'int', 'long' and 'Integer' System.out.println("in Number"); } static void overloadedMethod(int... i) { // will enter if comment 'int', 'long', 'Integer' and 'Number' System.out.println("in var arg"); } public static void main(String[] args) { overloadedMethod(10); } }

№11 слайд
Interface Defines a set of
Содержание слайда: Interface Defines a set of public abstract methods, which classes implementing the interface must provide. Allows you to define what a class can do without saying how to do it (interface is a contract) A class may implement multiple interfaces as well as extend classes that implement interfaces, allowing for limited multiple inheritance in Java May extend other interfaces, although they may not extend a class and vice versa May contain public static final constant values, public and private methods, public default methods.

№12 слайд
Interface interface Walk int
Содержание слайда: Interface interface Walk { int someConst = 1; public static final int anotherConst = 1; boolean isQuadruped(); private void doSomething() { //do some work } abstract double getMaxSpeed(); } interface Run extends Walk { public abstract boolean canHuntWhileRunning(); default double getMaxSpeed(){ return 1; } }

№13 слайд
Interface Provides a way for
Содержание слайда: Interface Provides a way for one individual to develop code that uses another individual’s code, without having access to the other individual’s underlying implementation. Interfaces can facilitate rapid application development by enabling development teams to create applications in parallel, rather than being directly dependent on each other (for example one team uses interface, another team implements it)

№14 слайд
Functional interface
Содержание слайда: Functional interface @FunctionalInterface interface Speakable { String say(); static void someStatic(){} default void someDefault(){} private void doSomething(){} }

№15 слайд
Nested Classes Types of
Содержание слайда: Nested Classes Types of nested classes: A member inner class is a class defined at the same level as instance variables. It is not static. Often, this is just referred to as an inner class without explicitly saying the type. A local inner class is defined within a method. An anonymous inner class is a special case of a local inner class that does not have a name. A static nested class is a static class that is defined at the same level as static variables.

№16 слайд
Nested Classes encapsulate
Содержание слайда: Nested Classes encapsulate helper classes by restricting them to the containing class make it easy to create a class that will be used in only one place can make the code easier to read.

№17 слайд
Member Inner Classes class A
Содержание слайда: Member Inner Classes class A { private int x = 1; class B { private int x = 2; class C { private int x = 3; public void printAll() { System.out.println(x); // 3 System.out.println(this.x); // 3 System.out.println(B.this.x); // 2 System.out.println(A.this.x); // 1 } } } }

№18 слайд
Local Inner Classes class
Содержание слайда: Local Inner Classes class Outer { private int length = 5; public void calculate() { final int width = 20; class Inner { public void multiply() { System.out.println(length * width); } } Inner inner = new Inner(); inner.multiply(); } }

№19 слайд
Anonymous Inner Classes
Содержание слайда: Anonymous Inner Classes public static void main(String[] args) throws Exception { JButton button = new JButton("red"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // handle the button click } }); }

№20 слайд
Static Nested Classes class
Содержание слайда: Static Nested Classes class Enclosing { static class Nested { private int price = 6; } public static void main(String[] args) { Nested nested = new Nested(); System.out.println(nested.price); } }

№21 слайд
Enum A special data type that
Содержание слайда: Enum A special data type that enables for a variable to be a set of predefined constants Has unique set of values Can implement interface Can NOT extend class Can contain fields and methods Singleton

№22 слайд
Enum enum Planet implements
Содержание слайда: Enum enum Planet implements IGravitable { MERCURY (3.303e+23, 2.4397e6) { @Override double surfaceGravity() { return -1; } }, VENUS (4.869e+24, 6.0518e6), EARTH (5.976e+24, 6.37814e6) // ... ; private double mass; // in kilograms final double radius; // in meters Planet(double mass, double radius) {// private this.mass = mass; this.radius = radius; } // universal gravitational constant (m3 kg-1 s-2) public static final double G = 6.67300E-11; @Override double surfaceGravity() { return G * mass / (radius * radius); } }

№23 слайд
Design principle A design
Содержание слайда: Design principle A design principle is an established idea or best practice that facilitates the software design process.

№24 слайд
Design principle More logical
Содержание слайда: Design principle More logical code Code that is easier to understand Classes that are easier to reuse in other relationships and applications Code that is easier to maintain and that adapts more readily to changes in the application requirements

№25 слайд
OOP principles Class Object
Содержание слайда: OOP principles Class Object Inheritance Encapsulation Polymorphism

№26 слайд
OOP principles Everything is
Содержание слайда: OOP principles Everything is object Object is a class instance Program – a set of interacting objects Object has a state and behavior

№27 слайд
Access modifiers public class
Содержание слайда: Access modifiers public class Dog { public String name = "Scooby-doo"; protected boolean hasFur = true; boolean hasPaws = true; private int id; }

№28 слайд
Encapsulation
Содержание слайда: Encapsulation

№29 слайд
Encapsulation
Содержание слайда: Encapsulation

№30 слайд
Encapsulation No actor other
Содержание слайда: Encapsulation No actor other than the class itself should have direct access to its data. The class is said to encapsulate the data it contains and prevent anyone from directly accessing it. With encapsulation, a class is able to maintain certain invariants about its internal data. An invariant is a property or truth that is maintained even after the data is modified.

№31 слайд
Encasulation example class
Содержание слайда: Encasulation example class CoffeeMachine { private int sugar; private double milk; Coffee makeCoffee(){ blendBeans(); heatWater(); shakeMilk(); return mix(); } private Coffee mix() { return new Coffee(); // mix all together } private void shakeMilk() { // shaking milk } private void heatWater() { // heating water } private void blendBeans() { // blending beans } }

№32 слайд
Encapsulation. Java Beans A
Содержание слайда: Encapsulation. Java Beans A JavaBean is a design principle for encapsulating data in an object in Java. private properties public getter(get, is for primitive boolean) public setter (set) property name in getter/setter starts with uppercase

№33 слайд
Encapsulation. Java Beans
Содержание слайда: Encapsulation. Java Beans What is wrong class Girl { private boolean playing; private Boolean dancing; public String name; … }

№34 слайд
Encapsulation. Java Beans
Содержание слайда: Encapsulation. Java Beans What is wrong class Girl { private boolean playing; private Boolean dancing; public String name; … }

№35 слайд
Polymorphism An object in
Содержание слайда: Polymorphism An object in Java may take on a variety of forms, in part depending on the reference used to access the object. One name, many forms. Polymorphism manifests itself by having multiple methods all with the same name, but slightly different functionality. There are 2 basic types of polymorphism. Overriding, also called run-time (dynamic) polymorphism. Overloading, which is referred to as compile-time (static) polymorphism.

№36 слайд
Polymorphism The type of the
Содержание слайда: Polymorphism The type of the object determines which properties exist within the object in memory. The type of the reference to the object determines which methods and variables are accessible to the Java program

№37 слайд
Polymorphism interface
Содержание слайда: Polymorphism interface LivesInOcean { void makeSound(); } class Dolphin implements LivesInOcean { public void makeSound() { System.out.println("whistle"); } } class Whale implements LivesInOcean { public void makeSound() { System.out.println("sing"); } }

№38 слайд
Polymorphism class Primate
Содержание слайда: Polymorphism class Primate { public boolean hasHair() { return true; } } interface HasTail { boolean isTailStriped(); } class Lemur extends Primate implements HasTail { public int age = 10; public boolean isTailStriped() { return false; } }

№39 слайд
Inheritance is-a
Содержание слайда: Inheritance (is-a)

№40 слайд
Inheritance is-a
Содержание слайда: Inheritance (is-a)

№41 слайд
Virtual methods invocation
Содержание слайда: Virtual methods invocation

№42 слайд
Composition has-a Object
Содержание слайда: Composition (has-a) Object composition is the idea of creating a class by connecting other classes as members using the has‐a principle. Inheritance is the idea of creating a class that inherits all of its reusable methods and objects from a parent class. Both are used to create complex data models, each with its own advantages and disadvantages

№43 слайд
Composition has-a class
Содержание слайда: Composition (has-a) class Person { Job job; public Person() { this.job = new Job(); job.setSalary(1000L); } public long getSalary() { return job.getSalary(); } }

№44 слайд
Literature https
Содержание слайда: Literature https://docs.oracle.com/javase/tutorial/java/javaOO/index.html https://docs.oracle.com/javase/tutorial/java/IandI/index.html https://docs.oracle.com/javase/tutorial/java/concepts/index.html

№45 слайд
Homework Implement classes
Содержание слайда: Homework Implement classes: SUV, Sedan, Hatchback3Doors, Hatchback5Doors SUV, Sedan, Hatchback3Doors, Hatchback5Doors should extend Vehicle Vehicle provides info: name, max passengers number, number of doors Vehicle should implement Drivable Each Vehicle contains Accelerator, BrakePedal, Engine, GasTank, SteeringWheel Implement Accelerator, BrakePedal, Engine, GasTank, SteeringWheel according to their names: Accelerator works 5 seconds (5 times) and speed-up the car for a some accelerateStrength BrakePedal slow down the car for a some brakingStrength Engine hat it capacity, max speed, can be started or stopped, uses fuel from GasTank when work GasTank has it max and current volumes, GasTank can use fuel or can be filled by it SteeringWheel has it max turn angle, current turn angle and step (one turn changes the current angle for this value), SteeringWheel can be turned left or right Verify all properties of each car part they cannot be greater than some max value and less than some min value (see tests); speed, volume cannot be negative or greater than max speed and/or volume Engine, GasTank, SteeringWheel should implement interface StatusAware Create class ControlPanel that must control the Drivable regardless of what type of vehicle it is transmitted

№46 слайд
Содержание слайда:

Скачать все slide презентации Java 4 WEB. Lesson 3 - OOP одним архивом: