Skip to content

Commit 1bb7544

Browse files
author
hussienalrubaye
committed
swift3
1 parent 4208fda commit 1bb7544

File tree

98 files changed

+1100
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1100
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//: Playground - noun: a place where people can play
2+
//direct//intial,access, print append remove
3+
import UIKit
4+
5+
//without array
6+
print("without array")
7+
var n1=10
8+
var n2=20
9+
var n3=30
10+
var n4=40
11+
print(n1)
12+
print(n2)
13+
print(n3)
14+
print(n4)
15+
16+
// with array
17+
print("with array")
18+
var ar=[10,20,30,40]
19+
for item in ar{
20+
print(item)
21+
}
22+
print("print with index")
23+
for index in 0...3 {
24+
print(ar[index])
25+
}
26+
/// array other
27+
28+
var ar2:[Any] = [10,3.4, "hello"]
29+
var ar3:[String] = ["10","3.4", "hello"]
30+
31+
32+
var jobs = [String]() //var jobs1 = Array<String>()
33+
jobs.append("engineer")
34+
jobs.append("developer")
35+
jobs.append("tester")
36+
jobs.remove(at: 1)
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<playground version='5.0' target-platform='ios'>
3+
<timeline fileName='timeline.xctimeline'/>
4+
</playground>

Swift 3/Arrays.playground/playground.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//: Playground - noun: a place where people can play
2+
3+
import UIKit
4+
//
5+
6+
class Car{
7+
//properties
8+
var type:String?
9+
var model:Int?
10+
var price:Double?
11+
var MilesDrive:Int?
12+
var Owner:String?
13+
14+
15+
//methods
16+
17+
func GetPrice() -> Double {
18+
19+
let NewPrice = price! - (Double)( MilesDrive! * 10 )
20+
return NewPrice
21+
}
22+
23+
func GetOwner() -> String {
24+
return Owner!
25+
}
26+
//init
27+
28+
init(type:String,model:Int,price:Double,MilesDrive:Int,Owner:String) {
29+
self.type=type
30+
self.model=model
31+
self.price=price
32+
self.MilesDrive=MilesDrive
33+
self.Owner=Owner
34+
print("Class created with parameter")
35+
}
36+
37+
init() {
38+
39+
print("Class created without parameter")
40+
}
41+
42+
43+
}
44+
45+
let car1 = Car(type: "BMW", model: 2016, price: 10000.2, MilesDrive: 20, Owner: "hussein alrubaye")
46+
car1.Owner="hussein alrubaye"
47+
let pricecar1 = car1.GetPrice()
48+
car1.GetOwner()
49+
50+
let car2 = Car()
51+
car2.type="Sony"
52+
car2.model=2016
53+
car2.price=10200.2
54+
car2.MilesDrive=10
55+
car2.Owner="Jena alrubaye"
56+
let pricecar2 = car1.GetPrice()
57+
car2.GetOwner()
58+
59+
60+
let carar = [Car]()
61+
62+
63+
64+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<playground version='5.0' target-platform='ios'>
3+
<timeline fileName='timeline.xctimeline'/>
4+
</playground>

Swift 3/ClassConstructor.playground/playground.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//: Playground - noun: a place where people can play
2+
// direct//intial,access, print append remove
3+
import UIKit
4+
var s=[2,5,8,8]
5+
var ar = Array<Any>()
6+
ar.append("hussein")
7+
ar.append("ahmed")
8+
ar.append("jena")
9+
print(ar.count)
10+
ar[0]
11+
ar.remove(at: 0)
12+
for item in ar {
13+
print(item)
14+
}
15+
16+
var dic = [Int:String]()
17+
dic[1]="hi"
18+
for (k,v) in dic {
19+
print(v)
20+
}
21+
var sets=Set<Int>()
22+
sets.insert(1)
23+
sets.insert(9)
24+
sets.insert(8)
25+
for item in sets {
26+
print(item)
27+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<playground version='5.0' target-platform='ios'>
3+
<timeline fileName='timeline.xctimeline'/>
4+
</playground>

0 commit comments

Comments
 (0)