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);
 }

}