androidアプリを作る 第1・2回

9b6ca173883528d3bd047ca8f20b0bce?s=47 nonylene
October 30, 2016

androidアプリを作る 第1・2回

9b6ca173883528d3bd047ca8f20b0bce?s=128

nonylene

October 30, 2016
Tweet

Transcript

  1. 9.

    "OESPJEͱ͸ w ಛ௃ w ແྉʢಛڐྉআ͘ʣ w ͍ΖΜͳϝʔΧʔ w 9QFSJB 40/:

    (BMBYZ 4BNTVOH  /FYVT (PPHMFͷ0&. )5$ FUD w ൺֱతࣗ༝౓͕ߴ͍ʢεϚʔτϑΥϯͷதͰ͸ʣ
  2. 12.
  3. 16.

    "OESPJEΞϓϦ͕ಈ͘·Ͱ w %BMWJL7. w +7.Ͱ͸ͳ͍ w d"OESPJE w "35 "OESPJE3VOUJNF

     w EFYΛ༧ΊίϯύΠϧͳͲˠૣ͍ʂྑ͍ʂ w "OESPJEd
  4. 17.
  5. 26.
  6. 35.
  7. 55.
  8. 67.

    w ͱΓ͋͑ͣ)FMMP8PSME • Hello.java )FMMP8PSME public class Hello { public

    static void main(String[] args) { System.out.println("Hello, world!"); } }
  9. 68.

    )FMMP8PSME $ javac Hello.java $ ls > Hello.class Hello.java $

    java Hello > Hello, world! ˡίϯύΠϧ
  10. 69.

    )FMMP8PSME $ javac Hello.java $ ls > Hello.class He… $

    java Hello > Hello, world! ˡόΠτίʔυ
  11. 72.

    • Hello.java • Hello Ϋϥεͷએݴ )FMMP8PSME public class Hello {

    public static void main(String[] args) { System.out.println("Hello, world!"); } }
  12. 73.

    • Hello.java • main ϝιου(≒ؔ਺)ͷએݴ )FMMP8PSME public class Hello {

    public static void main(String[] args) { System.out.println("Hello, world!"); } }
  13. 74.

    • Hello.java • System.out.println ϝιουΛݺͼग़͠ )FMMP8PSME public class Hello {

    public static void main(String[] args) { System.out.println("Hello, world!"); } }
  14. 75.

    public class Hello { public static void main(String[] args) {

    String hello = "Hello, world!”; System.out.println(hello); } } • Hello.java • hello ม਺ Λ࡞੒ )FMMP8PSME
  15. 82.

    public class Hello { … public static void printManga( String

    title, String author, String company, String bland, String volumeName, int price, String description, String obi) { System.out.println(author + "ͷ" + title + volumeName + "! " + company + bland + “ࣾӡΛ͔͚ͨ௒େ࡞!: \n આ໌͸ͪ͜Β” + description + obi + “஋ஈ͸” + price); } } એ఻༻จॻΛ࡞੒͢ΔϝιουΛ࡞Δ
  16. 83.

    public class Hello { … public static void printManga( String

    title, String author, String company, String bland, String volumeName, int price, String description, String obi) { System.out.println(author + "ͷ" + title + volumeName + "! " + company + bland + “ࣾӡΛ͔͚ͨ௒େ࡞!: \n આ໌͸ͪ͜Β” + description + obi + “஋ஈ͸” + price); } } એ఻༻จॻΛ࡞੒͢ΔϝιουΛ࡞Δ ˡඞཁͳม਺ୡ
  17. 84.

    public class Hello { … public static String getTitleFromServer(Server server)

    { server.getTitle().trim() } public static String getAuthorFromServer(Server server) { server.getAuthor().trim() } publ... } ອըσʔλΛαʔόʔ͔Β࣋ͬͯདྷΔ ˢ4USJOHҰͭͣͭஸೡʹฦ͢ϝιουΛ࡞Δ
  18. 85.

    public class Hello { public static void main(String[] args) {

    // server ͸ͳ͍͚Ͳઆ໌ͷͨΊ String title = getTitleFromServer(server); String author = getAuthorFromServer(server); Str… printManga(title, author, compa…); } ... } αʔόʔ͔Β͖࣋ͬͯͨ΋ͷΛએ఻༻จॻʹ͢Δ ˢม਺ΛҰͭҰͭऔಘ
  19. 86.

    public class Hello { public static void main(String[] args) {

    // server ͸ͳ͍͚Ͳઆ໌ͷͨΊ String title = getTitleFromServer(server); String author = getAuthorFromServer(server); Str… printManga(title, author, compa…); } ... } αʔόʔ͔Β͖࣋ͬͯͨ΋ͷΛએ఻༻จॻʹ͢Δ ˢม਺ΛҰͭҰͭϝιουʹೖΕ͍ͯ͘
  20. 87.

    public class Hello { public static void main(String[] args) {

    String title = getTitleFromServer(server); String author = getAuthorFromServer(server); Str… printManga(title, author, compa…); } public static void printManga( String title, String author, String company, String bland, String volumeName, int price, String description, String obi) { System.out.println(author + "ͷ" + title + volumeName + "! " + company + bland + “ࣾӡ Λ͔͚ͨ௒େ࡞!: \n આ໌͸ͪ͜Β” + description + obi + “஋ஈ͸” + price); } public static String getTitleFromServer(Server server) { server.getTitle() } public static String getAuthorFromServer(Server server) { server.getAuthor() } pub… ... } ·ͱΊΔ
  21. 89.

    public class Hello { … public static void printMangaShort( String

    title, //String author, //String company, //String bland, //String volumeName, int price, //String description, //String obi ) { System.out.println(titile + " Ձ֨: " + price); } } ୹͍એ఻จষͷ௥Ճ ˡཁΒͳ͍΋ͷ͸
 ίϝϯτΞ΢τ
  22. 90.

    public class Hello { public static void main(String[] args) {

    String title = getTitleFromServer(server); String author = getAuthorFromServer(server); Str… printManga(title, author, compa…); printMangaShort(title, price); } public static void printManga( String title, String author, String company, String bland, String volumeName, int price, String description, String obi) { System.out.println(author + "ͷ" + title + volumeName + "! " + company + bland + “ࣾӡΛ͔͚ͨ௒େ࡞!: \n આ໌͸ͪ͜Β” + description + obi + “஋ஈ͸” + price); } public static String getTitleFromServer(Server server) { server.getTitle() } public static String getAuthorFromServer(Server server) { server.getAuthor() } pub… public static void printMangaShort( String title, //String author, //String company, //String bland, //String volumeName, int price, //String description, //String obi ) { System.out.println(titile + " Ձ֨: " + price); } } ·ͱΊΔ
  23. 92.

    public class Hello { public static void main(String[] args) {

    String manga1Title = "ΏΔΏΓ"; String manga1Author = "ͳ΋Γ"; Str... String manga2Title = "ΏΏࣜ"; String manga2Author = "ࡾ্খຢ"; Str... printManga(manga1Title, manga1Author, ... ); printMangaShort(manga1Title, manga1Price); printManga(manga2Title, manga2Author, ... ); ॳظອը௥Ճ ˡ֤ม਺௥Ճ
  24. 93.

    public class Hello { public static void main(String[] args) {

    String manga1Title = "ΏΔΏΓ"; String manga1Author = "ͳ΋Γ"; Str... String manga2Title = "ΏΏࣜ"; String manga2Author = "ࡾ্খຢ"; Str... printManga(manga1Title, manga1Author, ... ); printMangaShort(manga1Title, manga1Price); printManga(manga2Title, manga2Author, ... ); ॳظອը௥Ճ ˡQSJOU
  25. 96.

    * Manga.java public class Manga { private String title; private

    String author; private String company; private String bland; private String volumeName; private int price; private String description; private String obi; public Manga(String title, String author, String company, String bland, String volumeName, int price, String description, String obi) { this.title = title; this.author = author; this.company = company; this.bland = bland; this.volumeName = volumeName; this.price = price; this.description = description; this.obi = obi; } } ˡ֤ม਺ʢϝϯόม਺ʣ
  26. 97.

    * Manga.java public class Manga { private String title; private

    String author; private String company; private String bland; private String volumeName; private int price; private String description; private String obi; public Manga(String title, String author, String company, String bland, String volumeName, int price, String description, String obi) { this.title = title; this.author = author; this.company = company; this.bland = bland; this.volumeName = volumeName; this.price = price; this.description = description; this.obi = obi; } } ˣੜ੒ɾॳظԽʢίϯετϥΫλʣ
  27. 98.

    * Manga.java public class Manga { private String title; private

    String author; private String company; private String bland; private String volumeName; private int price; private String description; private String obi; public Manga(String title, String author, String company, String bland, String volumeName, int price, String description, String obi) { this.title = title; this.author = author; this.company = company; this.bland = bland; this.volumeName = volumeName; this.price = price; this.description = description; this.obi = obi; } } ˡϝϯόม਺
 ʹ୅ೖ
  28. 99.

    public class Manga { … public void print() { System.out.println(author

    + "ͷ" + title + volumeName + "! " + company + bland + “ࣾӡΛ͔͚ͨ௒େ࡞!: \n આ໌͸ͪ͜Β” + description + obi + “஋ஈ͸” + price); } public void printShort() { System.out.println(titile + " Ձ֨: " + price); } } ˣΫϥε಺ͷม਺ΛಡΜͰprint
  29. 101.

    public class Hello { public static void main(String[] args) {

    Manga yuruyuri = new Manga("ΏΔΏΓ", "ͳ΋Γ", ...); Manga yuyushiki = new Manga("ΏΏࣜ", "ࡾ্খຢ", ...); yuruyuri.print(); yuruyuri.printShort(); yuyushiki.print(); yuyushiki.printShort(); // server ͳΜͯ΋ͷ͸ͳ͍͚Ͳઆ໌ͷͨΊ Manga manga = server.getManga(); manga.print(); manga.printShort(); } } ˢMangaΦϒδΣΫτΛ ࡞੒ɾॳظԽ
  30. 102.

    public class Hello { public static void main(String[] args) {

    Manga yuruyuri = new Manga("ΏΔΏΓ", "ͳ΋Γ", ...); Manga yuyushiki = new Manga("ΏΏࣜ", "ࡾ্খຢ", ...); yuruyuri.print(); yuruyuri.printShort(); yuyushiki.print(); yuyushiki.printShort(); // server ͳΜͯ΋ͷ͸ͳ͍͚Ͳઆ໌ͷͨΊ Manga manga = server.getManga(); manga.print(); manga.printShort(); } } ˢMangaΦϒδΣΫτ
  31. 103.

    public class Hello { public static void main(String[] args) {

    Manga yuruyuri = new Manga("ΏΔΏΓ", "ͳ΋Γ", ...); Manga yuyushiki = new Manga("ΏΏࣜ", "ࡾ্খຢ", ...); yuruyuri.print(); yuruyuri.printShort(); yuyushiki.print(); yuyushiki.printShort(); // server ͳΜͯ΋ͷ͸ͳ͍͚Ͳઆ໌ͷͨΊ Manga manga = server.getManga(); manga.print(); manga.printShort(); } } ˡMangaΫϥεʹఆٛ͞Εͨ ϝιουΛݺͿ
  32. 104.

    public class Hello { public static void main(String[] args) {

    Manga yuruyuri = new Manga("ΏΔΏΓ", "ͳ΋Γ", ...); Manga yuyushiki = new Manga("ΏΏࣜ", "ࡾ্খຢ", ...); yuruyuri.print(); yuruyuri.printShort(); yuyushiki.print(); yuyushiki.printShort(); // server ͳΜͯ΋ͷ͸ͳ͍͚Ͳઆ໌ͷͨΊ Manga manga = server.getManga(); manga.print(); manga.printShort(); } } ˡMangaΫϥεʹఆٛ͞Εͨ ϝιουΛݺͿ
  33. 105.

    public class Hello { public static void main(String[] args) {

    Manga yuruyuri = new Manga("ΏΔΏΓ", "ͳ΋Γ", ...); Manga yuyushiki = new Manga("ΏΏࣜ", "ࡾ্খຢ", ...); yuruyuri.print(); yuruyuri.printShort(); yuyushiki.print(); yuyushiki.printShort(); // server ͳΜͯ΋ͷ͸ͳ͍͚Ͳઆ໌ͷͨΊ Manga manga = server.getManga(); manga.print(); manga.printShort(); } } ˢMangaΦϒδΣΫτ͝ͱ
 αʔόʔ͔Βऔಘ ˞serverͰ͸MangaΦϒδΣΫτΛ࡞ͬͯฦ͢ॲཧΛॻ͍͍ͯΔͱ͢Δ
  34. 108.

    KBWBͰ͸ w Ұ෦Λআ͍ͯશͯΦϒδΣΫτͰߏ੒ w int / char / boolean ͳͲϓϦϛςΟϒܕͭҎ֎

    w จࣈྻ String ΋ΦϒδΣΫτ
 
 
 ˠΦϒδΣΫτࢦ޲ 001 ݴޠ String k = "KMC"; k.length(); k.replace("K", "O");