object oriented software development
play

Object Oriented Software Development Naufal F. Setiawan School of - PowerPoint PPT Presentation

Object Oriented Software Development Object Oriented Software Development Naufal F. Setiawan School of Computing and Information Systems University of Melbourne Workshop 3 ( Most images from Wikimedia Commons) Object Oriented Software


  1. Object Oriented Software Development Object Oriented Software Development Naufal F. Setiawan School of Computing and Information Systems University of Melbourne Workshop 3 ( Most images from Wikimedia Commons)

  2. Object Oriented Software Development Question 1: Java Input/Output By the end of this tutorial you will have an IDE. So we can do IO with Scanner instead of Grok’s heavily flawed Input class. Now, which next method in the Scanner class consumes the newline character? Answer

  3. Object Oriented Software Development Scanner.nextLine() 1 large latte with an extra shot \ n and a banana bread \ n plus 3 almond croissants \ n returned consumed

  4. Object Oriented Software Development Scanner.next() 1 large latte with an extra shot \ n and a banana bread \ n plus 3 almond croissants \ n returned consumed

  5. Object Oriented Software Development Question 1: Java Input/Output How much IO do we need to know for the exam and projects?

  6. Object Oriented Software Development You will not be asked to write IO in the exam Java IO C++ IO Python IO

  7. Object Oriented Software Development Arrays What are arrays and how do we initialize them? Answer

  8. Object Oriented Software Development Arrays What are arrays? Answer Arrays are fixed-size collections of references . How do we initialize them? Answer Type[] name = new Type[size]; int[] bigArray = new int[20];

  9. Object Oriented Software Development Arrays are objects... This means any variable containing arrays will be stored as references . marchPaydays happyDays [0] = 13 [1] = 27 Code int[] marchPaydays = { 13, 27 }; int[] happyDays = marchPaydays;

  10. Object Oriented Software Development Arrays are objects... So if you make changes to the array... marchPaydays happyDays [0] = 13 [1] = 30 Code marchPaydays[2] = 30; System.out.println(happyDays[2]) // outputs '30', not '27'

  11. Object Oriented Software Development Arrays of Objects Each element of the array is a reference. rhcp[0] rhcp[1] rhcp[2] rhcp[3] Example Pig[] redHotChilliPeppa = { new Pig(), new Pig(), new Pig(), new Pig() };

  12. Object Oriented Software Development Arrays of Objects Remember though, variables store arrays as references as well. Example Person[] uniStaff; Person[] uniStudents; Person naufal = new Person("Naufal") uniStaff[133307] = naufal; uniStudents[84XXXX] = naufal;

  13. Object Oriented Software Development Arrays of Objects staff student [133307] [8XXXXX] naufal

  14. Object Oriented Software Development Getting Started with Eclipse In the interest of fairness, SWEN20003 will officially support the Eclipse IDE (as other IDEs are not available on the lab computers). Eclipse Installation (Windows / Mac) You need to download: JDK8 (from Oracle’s website). Eclipse (or your favorite) IDE. Linux users (if any) are suggested to install openjdk8 and eclipse using their favorite package manager. You know what you’re doing.

  15. Object Oriented Software Development Kahoot Answers: Explanations Code int[] array1 = {12, 7, 0, 36, 11}; int[] array2 = array1; Arrays.sort(array1); System.out.println(array2[0]); array1 and array2 refers to the same array, if we sort one of them. Then the other one is also sorted!

  16. Object Oriented Software Development Kahoot Answers: Explanations Code String[] bestSubjects = {"SWEN20003", "COMP20007", "COMP30026", null, null, null}; System.out.println(bestSubjects.length); The length trap! array.length refers to the full maximum size of an array. (Answer = 5).

  17. Object Oriented Software Development Kahoot Answers: Explanations Code String[] bestSubjects = {"COMP10001", "COMP20007", "COMP30026", null, "SWEN20003"}; for (int i = 0; i < bestSubjects.length; ++i) { if (bestSubjects[i].equals("SWEN20003")) { System.out.println("big mood"); } } We see that bestSubjects[3] == null . We will get a NullPointerException because we tried to call null.equals("SWEN30006") . That will crash Java as null does not have an equals method.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend