chapter1 uml3

Download Chapter1 uml3

Post on 28-May-2015

361 views

Category:

Documents

2 download

Embed Size (px)

DESCRIPTION

บทที่ 7 วิธีการเชิงวัตถุและการออกแบบคลาส บทที่ 12 การเขียนโปรแกรมโดยใช้ NetBeans

TRANSCRIPT

  • 1. 7 Srinagarindra The Princess MotherSchoolKanchanaburi1

2. (Object Oriented) Object 2 3. Objects Object Object 3 4. Source Code Attributes, Functions Object Tools Tools 4 5. (Object) ( ) ( ) Object Message 5 6. Class Object Object Class Class Object Class (Abstract) Object (Concrete) Class Object Class Object 6 7. Student Class Class StudentID FirstName (Attributes) LastName (Operations Address Methods)TelephoneName Birthdate FacultyAttributes GPA Register()MethodsDrop() Withdraw() Class7Student 8. (Inheritance) Subclass (Attributes) Superclass MultipleInheritance Subclass Superclass 8 9. WithoutInheritanceWith 9 10. Object Object (Reusability) 10 11. 1. 2. 3. 11 12. Polymorphism Object Function/ Message Class Class Class Function draw() function Object Class Object Class 12 13. Polymorphismcode Object 13 14. Object Object Object Method Object Object Message Encapsulation 14 15. Object Public (+) Private (#) Class Protected (-) Subclass 15 16. Object Class 2 16 17. Object Class Whole-Part is part of Class Object Class 17 18. Object Class ClassClass Class Class 18 19. Object Class Class (Superclass) Class (Subclass)19 20. 12 NetBeansSrinagarindra The Princess MotherSchoolKanchanaburi20 21. NetBeans IDEFreeware Editor NetBeans Java, php, C/C++ download PlugIn NetBeans iReportPlugin reportVisual Web Page Layoutsweb21 22. NetBeansdownloadNetBeanshttp://netbeans.org/downloads/index.htmlNetBeansversionPlatformPlatformversion download.exefiledirectory NetBeansdesktop22 23. download .exefile directory NetBeansdesktop 23 24. JAVAdownloadJDKJavaDevelopmentKit downloadhttp://www.oracle.com/technetwork/java/javase/downloads/index downloadJDKSetclasspathCompileRunJava Linkhttp://archive.oracle.in.th/2008/02/set-path-class-path-j2se-dos.htmlhttp://www.dominixz.com/blog/software-tips/set-java-to-compile 24 25. NetBeans 4 25 26. Tool ProjectBrowseProjectFile Code Run debug 26 27. GUI NetBeans New Project File >> New Project 27 28. JavaJava Application Next 28 29. ProjectProject NameProjectNetBeansTutorialMain ClassMainClassFinish ProjectNetBeansTutorialFileMainClass.javaclass TestObj FuntionNetBeans class ProjectNew >> Java Class29 30. ClassTestObjFinish class TestObj code public class TestObj { private String firstName; private String lastName; public void showName() {System.out.println("THIS IS METHOD showName()");System.out.println("My name is "+firstName+" "+lastName); } } 30 31. AttributeClassTestObjprivateGetterand SetterNetBeansGetter andSetterAttribute codeInsertCode Getterand Setter Generate Getters andSetters Getters and Setters31 32. codeclass TestObjpublicvoidsetFirst publicclassTestObj {Name(String firstName) privateStringfirstName; { privateStringlastName;this.firstName = firstName; publicvoidshowName() { } System.out.println("THIS IS METHOD showName()"); publicString System.out.println("My name is "+firstName+""+lastName);getLastName() { } returnlastNam e; publicString getFirstName() { } returnfirstName; } publicvoidsetLast Name(String lastName){32this.lastName= 33. Generate Getters and Setters FunctionNetBeans class TestObj codeMainClass publicclassMainClass { publicstaticvoidmain(String[] args) { TestObj temp =newTestObj(); temp.setFirstName("Itthi"); temp.setLastName("Kruenarongkul"); temp.showName(); temp.setFirstName("Monthinee"); temp.setLastName("Buntawee"); temp.showName();33 34. code CTRL +SpaceBarmethodAttribute NetBeans Code Run 34 35. NetBeansSaveRunNetBeanscompileerror35