$30 off During Our Annual Pro Sale. View Details »

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

nonylene
October 30, 2016

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

nonylene

October 30, 2016
Tweet

More Decks by nonylene

Other Decks in Technology

Transcript

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

    (BMBYZ 4BNTVOH  /FYVT (PPHMFͷ0&. )5$ FUD w ൺֱతࣗ༝౓͕ߴ͍ʢεϚʔτϑΥϯͷதͰ͸ʣ
  2. "OESPJEΞϓϦ͕ಈ͘·Ͱ w %BMWJL7. w +7.Ͱ͸ͳ͍ w d"OESPJE w "35 "OESPJE3VOUJNF

     w EFYΛ༧ΊίϯύΠϧͳͲˠૣ͍ʂྑ͍ʂ w "OESPJEd
  3. w ͱΓ͋͑ͣ)FMMP8PSME • Hello.java )FMMP8PSME public class Hello { public

    static void main(String[] args) { System.out.println("Hello, world!"); } }
  4. )FMMP8PSME $ javac Hello.java $ ls > Hello.class Hello.java $

    java Hello > Hello, world! ˡίϯύΠϧ
  5. )FMMP8PSME $ javac Hello.java $ ls > Hello.class He… $

    java Hello > Hello, world! ˡόΠτίʔυ
  6. • Hello.java • Hello Ϋϥεͷએݴ )FMMP8PSME public class Hello {

    public static void main(String[] args) { System.out.println("Hello, world!"); } }
  7. • Hello.java • main ϝιου(≒ؔ਺)ͷએݴ )FMMP8PSME public class Hello {

    public static void main(String[] args) { System.out.println("Hello, world!"); } }
  8. • Hello.java • System.out.println ϝιουΛݺͼग़͠ )FMMP8PSME public class Hello {

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

    String hello = "Hello, world!”; System.out.println(hello); } } • Hello.java • hello ม਺ Λ࡞੒ )FMMP8PSME
  10. 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); } } એ఻༻จॻΛ࡞੒͢ΔϝιουΛ࡞Δ
  11. 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); } } એ఻༻จॻΛ࡞੒͢ΔϝιουΛ࡞Δ ˡඞཁͳม਺ୡ
  12. public class Hello { … public static String getTitleFromServer(Server server)

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

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

    // server ͸ͳ͍͚Ͳઆ໌ͷͨΊ String title = getTitleFromServer(server); String author = getAuthorFromServer(server); Str… printManga(title, author, compa…); } ... } αʔόʔ͔Β͖࣋ͬͯͨ΋ͷΛએ఻༻จॻʹ͢Δ ˢม਺ΛҰͭҰͭϝιουʹೖΕ͍ͯ͘
  15. 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… ... } ·ͱΊΔ
  16. 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); } } ୹͍એ఻จষͷ௥Ճ ˡཁΒͳ͍΋ͷ͸
 ίϝϯτΞ΢τ
  17. 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); } } ·ͱΊΔ
  18. 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, ... ); ॳظອը௥Ճ ˡ֤ม਺௥Ճ
  19. 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
  20. * 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; } } ˡ֤ม਺ʢϝϯόม਺ʣ
  21. * 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; } } ˣੜ੒ɾॳظԽʢίϯετϥΫλʣ
  22. * 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; } } ˡϝϯόม਺
 ʹ୅ೖ
  23. 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
  24. 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ΦϒδΣΫτΛ ࡞੒ɾॳظԽ
  25. 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ΦϒδΣΫτ
  26. 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Ϋϥεʹఆٛ͞Εͨ ϝιουΛݺͿ
  27. 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Ϋϥεʹఆٛ͞Εͨ ϝιουΛݺͿ
  28. 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ΦϒδΣΫτΛ࡞ͬͯฦ͢ॲཧΛॻ͍͍ͯΔͱ͢Δ
  29. KBWBͰ͸ w Ұ෦Λআ͍ͯશͯΦϒδΣΫτͰߏ੒ w int / char / boolean ͳͲϓϦϛςΟϒܕͭҎ֎

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