2013年9月27日 星期五

【職訓局-手機程式開發班】2013 9/26 Xcode

1.認證憑證及電腦





2.xib寫Helloworld




 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3.storyboard寫Helloworld



4.發布到手機

2013年9月24日 星期二

2013年9月23日 星期一

【職訓局-手機程式開發班】2013 9/23 java

1.StringBuffer 與 StringBuilder

字串需一直變動使用String每變動一次都會產生新的物件,
會浪費記憶體,這時就要用StringBuffer與StringBuiler,
StringBuiler不能使用在多執行序。

StringBuffer b = new StringBuffer("12345"); // 創立文字
b.append("6789"); // 加入文字
System.out.println(b);
b.delete(2, 4); // 刪除文字 (開始,結束)
System.out.println(b);
b.insert(3, "34"); // 增加文字 (開始,插入值)
System.out.println(b);
b.replace(1, 5, "二三四"); // 取代(開始,結束,值) 只會取代開始與結束中間的值
System.out.println(b);
b.reverse(); // 顛倒
System.out.println(b);
b.reverse(); // 顛倒
  
String a = new String(b);
String c = a.replaceAll("二三四", "234"); // 正規法取代
System.out.println(c);

執行結果:
1256789
125346789
1二三四6789
9876四三二1
12346789

2.規則表示法

例1:
String s = "123456789";
System.out.println(s.matches("[0-9]")); // false (只比對一位數 s="1"才會是true)
System.out.println(s.matches("[0-9]+")); // ture (+至少出現1次以上的數字)
System.out.println(s.matches("[0-9]*")); // ture (*0或多次)
System.out.println(s.matches("[0-9]{9}")); // ture (剛好出現9個)
System.out.println(s.matches("[0-9]{3,}")); // ture (3個以上)
System.out.println(s.matches("[0-9]{3,8}")); // false (3-8個)

String b = "123";
System.out.println(b.matches("1[^123]3")); // false (^是不包含)
System.out.println(b.matches("1[123]3")); // true
System.out.println(b.matches("1([123])+3")); // true ()為群組
// 手機號碼檢查 String b = "0935751111"; System.out.println(b.matches("0[0-9]{9}")); // true // Eamil String b = "leeeee@yahoo.com.tw"; String b = "leeeee@yahoo.com.tw"; System.out.println(b.matches("[A-Za-z_]{1}[A-Za-z1-9_\\.]*@[A-Za-z1-9_]{1}[A-Za-z1-9_\\.]*")); // true // 簡易身分證 String b = "C222990912"; System.out.println(b.matches("[A-Z]{1}[12]{1}[0-9]{8}")); // true

3.split (explode)

String a = "1,2,3,4,5";
String[] c = a.split(",");
for(String i:c){
 System.out.print(i); // 12345
}

2013年9月18日 星期三

【職訓局-手機程式開發班】2013 9/18 ObjC

1.函數前面為加號為靜態可直接使用不須init

例:

+ (float) PI{
    float pi = 3.14;
    return pi;
}

NSLog(@"%f",[Test PI]); // 這邊就可直接使用

2.全域變數使用

#import "Test.h"

int gTest = 5; // 宣告時前面要加個小g代表是全域變數

int main(int argc, const char * argv[])
{

    @autoreleasepool {
        
        Test *T = [[Test alloc] init];
        
        NSLog(@"%f",[Test PI]);
        
        NSLog(@"%i",[T TestG:10]); // 列印出10
        
        
    }
    return 0;
}

Test.m
- (int) TestG:(int)val{
    extern int gTest;
    gTest = val;
    return gTest;
}

3.物件初始化

test.m

- (id) initR:(float)setR{
    self = [super init];
    if (self){
        self.r = setR;
    }
    return self;
}

int main(int argc, const char * argv[])
{

    @autoreleasepool {
        
        //Test *T = [[Test alloc] init];
        
        Test *T = [[Test alloc] initR:20]; // 可以多個初始化
        
        //T.r = 10;
        
        NSLog(@"%f",[T area]);
        
        
    }
    return 0;
}

4.靜態變數static

static int count = 0;
- (int) getCount{
    return count;
}

main.m
NSLog(@"%i",[T getCount]); // return 1
NSLog(@"%i",[T getCount]); // return 2

2013年9月14日 星期六

【職訓局-手機程式開發班】2013 9/14 網路基礎

1.同網段可直接傳檔案,不同要由路由器傳








2.不同網域互傳
DATA
進入TCP UDP (TCP:可靠傳輸,UDP:不可靠)
會加入本機電腦的PORT跟對方的PORT加入
進入IP後會加入本機電腦跟對方的電腦

2013年9月13日 星期五

夢想不能等

貧窮不能等,因為時間久了,你就會貧窮習慣了;
學習不能等,因為努力晚了,人老就無能為力了;
夢想不能等,因為懂得少了,就沒本事夢想成真了;
健康不能等,因為身體垮了,人生的一切就都沒了。

你不能決定生命的長度,但可以控制它的寬度;
你不能左右天氣,但可以改變心情;
你不能改變容顏,但可以展現笑容;
你不能控制他人,但可以掌握自己;
你不能預知明天,但可以利用今天;
你不能樣樣勝利,但可以事事盡力。

【freego】逃避它的方法

$_SERVER['HTTP_USER_AGENT'] = Java/1.7.0_21
就跳過

2013年9月12日 星期四

【職訓局-手機程式開發班】2013 9/11 java

CLASS ex1:
class aa{
public int x, y;
public bb b;

aa(int x, int y){
this.x = x;
this.y = y;
b = new bb(this.x, this.y);
}

public String area(){
return  "x:" + this.x + ",y:" + this.y + ",面積為:" + b.area();
}

public String perimeter(){
return "x:" + this.x + ",y:" + this.y + ",邊長為:" + b.perimeter();
}

}

class bb{
public int x, y;
public cc c;

bb(int x, int y){
this.x = x;
this.y = y;
c = new cc(this.x, this.y);
}

public int area(){
return this.x * this.y;
}

public int perimeter(){
return c.perimeter();
}
}

class cc{
public int x, y;

cc(int x, int y){
this.x = x;
this.y = y;
}

public int perimeter(){
return 2 * (this.x + this.y);
}
}


public class test01 {

public static void main(String[] args) {
aa a = new aa(10,20);
a.b.x = 100;
System.out.println(a.area());
a.b.c.x = 1000;
System.out.println(a.perimeter());
}

}
CLASS ex2:
package ch09;

class aa{
public int x, y;
public bb b;

aa(int x, int y){
this.x = x;
this.y = y;
b = new bb(this.x, this.y);
}

public String area(){
return  "x:" + this.x + ",y:" + this.y + ",面積為:" + b.area();
}

public String perimeter(){
return "x:" + this.x + ",y:" + this.y + ",邊長為:" + b.perimeter();
}

}

class bb{
public int x, y;
public cc c;

bb(int x, int y){
this.x = x;
this.y = y;
c = new cc(this.x, this.y);
}

public int area(){
return this.x * this.y;
}

public int perimeter(){
return c.perimeter();
}
}

class cc{
public int x, y;

cc(int x, int y){
this.x = x;
this.y = y;
}

public int perimeter(){
return 2 * (this.x + this.y);
}
}


public class test01 {

public static void main(String[] args) {
aa a = new aa(10,20);
a.b.x = 100;
System.out.println(a.area());
a.b.c.x = 1000;
System.out.println(a.perimeter());
}


}

2013年9月11日 星期三

【語言比較】1.class

JAVA 

class:
class a01{
    private int x;
    int y;
   
    public void setx(int x){
        this.x = x;
    }
   
    public int getx(){
        return this.x;
    }
   
    public int area(){
        return this.x * this.y;
    }
}

使用
a01 a = new a01();
a.setx(10);
a.y = 20;
system.out.print(a.area());

ObjectiveC

a01.h檔
@property int x,y;

- (void) setx:(int)x;
- (int) getx();
- (int) area();

a01.m檔
@synthesize x,y;
- (void) setx:(int)setX{
    x = setX;
}
- (int) getx(){
  return x;
}
- (int) area(){
  return x*y;
}

使用
a01 *a = [[a01 alloc] init]
[a setx:10]
a.y = 20;
NSLog(@"%i",[a area]);


PHP

class:
class a01{
private $x;
public $y;
public function setx($x){
$this->x = $x;
public function getx(){
return $this->x;
}
public function area(){
return $this->x * $this->y;
}
}

使用
$a = new a01();
$a->setx(10);
$a->y = 20;
echo $a->area();

Javascript (網頁)

class:
function a01() {  
this.x;
this.y;

    this.setx = function(x) {  
        this.x = x;
    }
this.getx = function(){
return this.x;
}
this.area = function(){
return this.x * this.y;
}
}

使用
var a = new a01();
a.setx(10);
a.y = 20;
document.write(a.area());

【mysql】不常用語法

1. is Null
SELECT * FROM user WHERE address is Null

2.is not Null
SELECT * FROM user WHERE address is not Null

3.not like
SELECT * FROM user WHERE address not like '_中%'

4.view 建立及移除暫存資料表
create view tmp as SELECT * FROM user WHERE address is Null
drop view tmp

5.distinct 重複的不計
SELECT count(distinct address) FROM user WHERE address is Null

2013年9月9日 星期一

2013年9月5日 星期四

【職訓局-手機程式開發班】2013 9/4 Java

1.參照
package test;

class A{
 int aa = 10;
}


class B{
 void c(A a){ // 可以傳類別近來
  a.aa = 3;
 }
}

public class class_text {

 public static void main(String[] args) {
  A a = new A();
  B b = new B();
  
  b.c(a);
  
  System.out.println(a.aa); // a.aa = 3
  
 }

}
2.呼叫自己的function
package test;

public class class_test2 {

 int i;
 
 public static void main(String[] args) {
  
  class_test2 c = new class_test2(); // 自己
  c.i = 10;
  c.A();
  
 }
 
 void A(){
  System.out.println(i);
 }

}

2013年9月2日 星期一

【職訓局-手機程式開發班】2013 8/28 Unity coding

1.var private static

2.滑鼠及旋轉0左1右


3.鍵盤事件

4.rigidbody 設定

5.2D遊戲攝影機

6.限制移動範圍

7.生成物件Instantiate(cube, transform.position, Quaternion.identity);

8.抓取產生的物件

9.物件消失