Revisão Herança Polimorfismo Classes Abstratas Interface.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

1 Editor Gráfico Alcides Calsavara. 2 Interface Forma Cor Desenho.
Introduction to Computer Science Robert Sedgewick and Kevin Wayne Recursive Factorial Demo pubic class Factorial {
Conceitos Fundamentais de Orientação a Objetos. Grupo de Estudo de Java Joselito Seção 1.
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
Exercício de Interfaces O código terá erro de compilação ou executará normalmente?
CS102--Object Oriented Programming Review 1: Chapter 1 – Chapter 7 Copyright © 2008 Xiaoyan Li.
Презентація за розділом “Гумористичні твори”
Центр атестації педагогічних працівників 2014
Галактики і квазари.
Характеристика ІНДІЇ.
Процюк Н.В. вчитель початкових класів Боярської ЗОШ І – ІІІ ст №4
Public static void main( String [] args ){ getBinaryNumberFromUser(); //asks the user to type a binary number while( notDone() ){ int binary_digit = getNextDigit();
Solución 3 (más natural) static public int mayor(int x, int y) { if( x > y ) return x; else return y; } ¿Significado? si x es mayor que y, entonces entregar.
1 Linear and Binary Search Instructor: Mainak Chaudhuri
Interfaces. –An interface describes a set of methods: no constructors no instance variables –The interface must be implemented by some class. 646 java.
1 Graph Coverage (4). Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Section
Miscellaneous topics Chapter 2 Savitch. Miscellaneous topics Standard output using System.out Input using Scanner class.
$100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300.
CIS 270—Application Development II Chapter 18-Generics.
Overriding toString()
Духовні символи Голосіївського району
Java and C++ Transitioning. A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello.
Object Oriented Programming in Java Lecture 14. Review Quiz 1. Write a method which gets an Object and call all its available ‘get’ Methods and print.
Output Programs These slides will present a variety of small programs. Each program has some type of array that was introduced in this chapter. Our concern.
1 Insertion sort [ ] i=1 j=1 i=2 j=2 insert i=3 at j=1 [ ] i=3 j=1 insert i=4 at j=0 [
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
1 Interfaces and Abstract Classes The ability to define the behavior of an object without specifying that behavior is to be implemented Interface class.
Computer Programming Lab 9. Exercise 1 Source Code package excercise1; import java.util.Scanner; public class Excercise1 { public static void main(String[]
Simple Console Output CS 21a. What we will briefly discuss System.out.println( … ) System.out.print( … ) System.out.printf( … )
Programación I Estructuras de control Java. IF- Else.
Staples are our staple Building upon our solution.
Three kinds of looping structures The while loop The for loop The do (also called the do-while) loop All have equivalent power, e.g., if you can write.
Account verification Prova di upload da formato PPT.
Sum of natural numbers class SumOfNaturalNumbers {
Maha AlSaif Maryam AlQattan
Data Structures Array - Code.
null, true, and false are also reserved.
TO COMPLETE THE FOLLOWING:
Chapter 11: More on the Implications of Inheritance
CSC 113: Computer programming II
Data Structures Array - Code.
CS 180 Assignment 6 Arrays.
Проф. д-р Васил Цанов, Институт за икономически изследвания при БАН
ЗУТ ПРОЕКТ на Закон за изменение и допълнение на ЗУТ
О Б Щ И Н А С И Л И С Т Р А П р о е к т Б ю д ж е т г.
Електронни услуги на НАП
Боряна Георгиева – директор на
РАЙОНЕН СЪД - БУРГАС РАБОТНА СРЕЩА СЪС СЪДЕБНИТЕ ЗАСЕДАТЕЛИ ПРИ РАЙОНЕН СЪД – БУРГАС 21 ОКТОМВРИ 2016 г.
Сътрудничество между полицията и другите специалисти в България
Съобщение Ръководството на НУ “Христо Ботев“ – гр. Елин Пелин
НАЦИОНАЛНА АГЕНЦИЯ ЗА ПРИХОДИТЕ
ДОБРОВОЛЕН РЕЗЕРВ НА ВЪОРЪЖЕНИТЕ СИЛИ НА РЕПУБЛИКА БЪЛГАРИЯ
Съвременни софтуерни решения
ПО ПЧЕЛАРСТВО ЗА ТРИГОДИШНИЯ
от проучване на общественото мнение,
Васил Големански Ноември, 2006
Програма за развитие на селските райони
ОПЕРАТИВНА ПРОГРАМА “АДМИНИСТРАТИВЕН КАПАЦИТЕТ”
БАЛИСТИКА НА ТЯЛО ПРИ СВОБОДНО ПАДАНЕ В ЗЕМНАТА АТМОСФЕРА
МЕДИЦИНСКИ УНИВЕРСИТЕТ – ПЛЕВЕН
Стратегия за развитие на клъстера 2015
Моето наследствено призвание
Правна кантора “Джингов, Гугински, Кючуков & Величков”
Безопасност на движението
writeSpaces(10); | V +--->--->--->--->--->---+
Debugging Exercise 00 Try compiling the code samples.
Generics 5/11/2019.
Agenda Types and identifiers Practice Assignment Keywords in Java
Presentation transcript:

Revisão Herança Polimorfismo Classes Abstratas Interface

2 Desafio – Aula05

3 1.public class Principal{ 2. // Método main 3. public static void main ( String argv[]) { Object objetos[] = new Object[3];// array 6. objetos[0] = new CartaoProva (75, 25); O que aconteceria se fosse do tipo Pontucao?

4 Desafio – Aula05 1. for ( Object esteObjeto : objetos ){ 2. if (esteObjeto instanceof CartaoProva) { 3. CartaoProva prova = (CartaoProva)esteObjeto; 4. System.out.printf ("\nPontos da prova: %.0f\n",prova.calcularPontos()); 5. } 6. if (esteObjeto instanceof ClubeFutebol) { 7. ClubeFutebol futebol = (ClubeFutebol)esteObjeto; 8. System.out.printf ("\nPontos do campeonato: %.0f\n",futebol.calcularPontos()); 9. } 10. if (esteObjeto instanceof ClubeInvestimentos) { 11. ClubeInvestimentos investimento = (ClubeInvestimentos)esteObjeto; 12. System.out.printf ("\nPontos no mercado: %.2f\n\n",investimento.calcularPontos()); 13. } 14. } // fim do for

5 Exercício Empregado

6 public class Principal{ // Testando o projeto public static void main ( String argv[]) { Pagamento pagamentos[] = new Pagamento[5];// array O que aconteceria se fosse do tipo Empregado?

7 Exercício Empregado 1.for (Pagamento pagamentoCorrente : pagamentos){ 2. if (pagamentoCorrente instanceof Empregado) { 3. Empregado emp = (Empregado) pagamentoCorrente; 4. System.out.println ("Empregado:" + emp.getNome()); 5. } 6. else { 7. Fatura fatura = (Fatura) pagamentoCorrente; 8. System.out.println("Fatura:" + fatura.getNome()); 9. } 10. System.out.println("Pagamento: R$ " String.format("%.2f",pagamentoCorrente.calcularPagamento())); 12. } // fim do for