using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class a1_1 : MonoBehaviour {
public int nomerPilihan = 0, batasMaxLooping = 10;
private int number = 0, ax = 1, next,cek,cek2;
private string kosong="",bintang = "*",nextB;
private ArrayList fibonachi;
// Use this for initialization
void Start () {
//created array list
fibonachi = new ArrayList ();
switch(nomerPilihan){
//For Fibonachi 1.1
case 1:
for (int a = 1; a <= batasMaxLooping; a++) {
fibonachi.Add (number);
next = number + ax;
number = ax;
ax = next;
}
foreach (int aAra in fibonachi) {
Debug.Log (aAra);
}
break;
//while fibonachi 1.2
case 2:
int a2 = 1;
while (a2 <= batasMaxLooping) {
fibonachi.Add (number);
next = number + ax;
number = ax;
ax = next;
a2++;
}
foreach (int aAra in fibonachi) {
Debug.Log (aAra);
}
break;
//do while fibonachi 1.3
case 3:
int a3 = 1;
do {
fibonachi.Add (number);
next = number + ax;
number = ax;
ax = next;
a3++;
} while(a3 <= batasMaxLooping);
foreach (int aAra in fibonachi) {
Debug.Log (aAra);
}
break;
//For Fibonachi 2.1
case 4:
for (int b = 1; b <= 10; b++) {
fibonachi.Add (number);
next = number + ax;
number = ax;
ax = next;
}
Debug.Log (" "+ fibonachi [0] +" - "+ fibonachi [1] +" - "+ fibonachi [2] + " - "
+ fibonachi [3] +" - "+ fibonachi [4] +" - "+ fibonachi [5] +" - "
+ fibonachi [6] +" - "+ fibonachi [7] +" - "+ fibonachi [8] +" - "
+ fibonachi [9]);
break;
case 5:
int bb2 = 1;
while (bb2 <= 10) {
fibonachi.Add (number);
next = number + ax;
number = ax;
ax = next;
bb2++;
}
Debug.Log (" "+ fibonachi [0] +" - "+ fibonachi [1] +" - "+ fibonachi [2] + " - "
+ fibonachi [3] +" - "+ fibonachi [4] +" - "+ fibonachi [5] +" - "
+ fibonachi [6] +" - "+ fibonachi [7] +" - "+ fibonachi [8] +" - "
+ fibonachi [9]);
break;
case 6:
int aaa3 = 1;
do {
fibonachi.Add (number);
next = number + ax;
number = ax;
ax = next;
aaa3++;
} while(aaa3 <= 10);
Debug.Log (" "+ fibonachi [0] +" - "+ fibonachi [1] +" - "+ fibonachi [2] + " - "
+ fibonachi [3] +" - "+ fibonachi [4] +" - "+ fibonachi [5] +" - "
+ fibonachi [6] +" - "+ fibonachi [7] +" - "+ fibonachi [8] +" - "
+ fibonachi [9]);
break;
//For Fibonachi 3.1
case 7:
for (int b = 1; b <= batasMaxLooping; b++) {
Debug.Log(kosong);
nextB = kosong + bintang;
kosong = bintang;
bintang = nextB;
}
break;
case 8:
int b2 = 1;
while (b2 <= batasMaxLooping) {
Debug.Log(kosong);
nextB = kosong + bintang;
kosong = bintang;
bintang = nextB;
b2++;
}
break;
case 9:
int b3 = 1;
do {
Debug.Log(kosong);
nextB = kosong + bintang;
kosong = bintang;
bintang = nextB;
b3++;
} while(b3 <= batasMaxLooping);
break;
default:
Debug.Log ("Nomer Permintaan Tidak Ada");
break;
}
//ceking do update
Debug.Log ("1.Looping for Down 2.Looping while Down 3.Looping do while Down 4.Looping for Line 5.Looping while Line");
Debug.Log ("6.Looping do while Line 7.Looping for ** 8.Looping while ** 9.Looping do while **");
cek = batasMaxLooping;
cek2 = nomerPilihan;
}
// Update is called once per frame
void Update () {
if(cek!=batasMaxLooping||cek2!=nomerPilihan){
number = 0;
ax = 1;
kosong = "";
bintang = "*";
if (fibonachi.Count > 1) {
fibonachi.Clear ();
}
Start ();
}
}
}
using System.Collections.Generic;
using UnityEngine;
public class a1_1 : MonoBehaviour {
public int nomerPilihan = 0, batasMaxLooping = 10;
private int number = 0, ax = 1, next,cek,cek2;
private string kosong="",bintang = "*",nextB;
private ArrayList fibonachi;
// Use this for initialization
void Start () {
//created array list
fibonachi = new ArrayList ();
switch(nomerPilihan){
//For Fibonachi 1.1
case 1:
for (int a = 1; a <= batasMaxLooping; a++) {
fibonachi.Add (number);
next = number + ax;
number = ax;
ax = next;
}
foreach (int aAra in fibonachi) {
Debug.Log (aAra);
}
break;
//while fibonachi 1.2
case 2:
int a2 = 1;
while (a2 <= batasMaxLooping) {
fibonachi.Add (number);
next = number + ax;
number = ax;
ax = next;
a2++;
}
foreach (int aAra in fibonachi) {
Debug.Log (aAra);
}
break;
//do while fibonachi 1.3
case 3:
int a3 = 1;
do {
fibonachi.Add (number);
next = number + ax;
number = ax;
ax = next;
a3++;
} while(a3 <= batasMaxLooping);
foreach (int aAra in fibonachi) {
Debug.Log (aAra);
}
break;
//For Fibonachi 2.1
case 4:
for (int b = 1; b <= 10; b++) {
fibonachi.Add (number);
next = number + ax;
number = ax;
ax = next;
}
Debug.Log (" "+ fibonachi [0] +" - "+ fibonachi [1] +" - "+ fibonachi [2] + " - "
+ fibonachi [3] +" - "+ fibonachi [4] +" - "+ fibonachi [5] +" - "
+ fibonachi [6] +" - "+ fibonachi [7] +" - "+ fibonachi [8] +" - "
+ fibonachi [9]);
break;
case 5:
int bb2 = 1;
while (bb2 <= 10) {
fibonachi.Add (number);
next = number + ax;
number = ax;
ax = next;
bb2++;
}
Debug.Log (" "+ fibonachi [0] +" - "+ fibonachi [1] +" - "+ fibonachi [2] + " - "
+ fibonachi [3] +" - "+ fibonachi [4] +" - "+ fibonachi [5] +" - "
+ fibonachi [6] +" - "+ fibonachi [7] +" - "+ fibonachi [8] +" - "
+ fibonachi [9]);
break;
case 6:
int aaa3 = 1;
do {
fibonachi.Add (number);
next = number + ax;
number = ax;
ax = next;
aaa3++;
} while(aaa3 <= 10);
Debug.Log (" "+ fibonachi [0] +" - "+ fibonachi [1] +" - "+ fibonachi [2] + " - "
+ fibonachi [3] +" - "+ fibonachi [4] +" - "+ fibonachi [5] +" - "
+ fibonachi [6] +" - "+ fibonachi [7] +" - "+ fibonachi [8] +" - "
+ fibonachi [9]);
break;
//For Fibonachi 3.1
case 7:
for (int b = 1; b <= batasMaxLooping; b++) {
Debug.Log(kosong);
nextB = kosong + bintang;
kosong = bintang;
bintang = nextB;
}
break;
case 8:
int b2 = 1;
while (b2 <= batasMaxLooping) {
Debug.Log(kosong);
nextB = kosong + bintang;
kosong = bintang;
bintang = nextB;
b2++;
}
break;
case 9:
int b3 = 1;
do {
Debug.Log(kosong);
nextB = kosong + bintang;
kosong = bintang;
bintang = nextB;
b3++;
} while(b3 <= batasMaxLooping);
break;
default:
Debug.Log ("Nomer Permintaan Tidak Ada");
break;
}
//ceking do update
Debug.Log ("1.Looping for Down 2.Looping while Down 3.Looping do while Down 4.Looping for Line 5.Looping while Line");
Debug.Log ("6.Looping do while Line 7.Looping for ** 8.Looping while ** 9.Looping do while **");
cek = batasMaxLooping;
cek2 = nomerPilihan;
}
// Update is called once per frame
void Update () {
if(cek!=batasMaxLooping||cek2!=nomerPilihan){
number = 0;
ax = 1;
kosong = "";
bintang = "*";
if (fibonachi.Count > 1) {
fibonachi.Clear ();
}
Start ();
}
}
}
SEMOGA BERMANFAAT MAS BRO.. untuk nomer fibonachi kesamping pakek case 4 ya:
kalo kalian pake satu file aja coba copy nih script:
kalo kalian pake satu file aja coba copy nih script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class a1_1 : MonoBehaviour {
private ArrayList fibonachi;
private int number = 0, ax = 1, next;
void Start () {
fibonachi = new ArrayList ();
}
private ArrayList fibonachi;
private int number = 0, ax = 1, next;
void Start () {
fibonachi = new ArrayList ();
for (int b = 1; b <= 10; b++) {
fibonachi.Add (number);
next = number + ax;
number = ax;
ax = next;
}
Debug.Log (" "+ fibonachi [0] +" - "+ fibonachi [1] +" - "+ fibonachi [2] + " - "
+ fibonachi [3] +" - "+ fibonachi [4] +" - "+ fibonachi [5] +" - "
+ fibonachi [6] +" - "+ fibonachi [7] +" - "+ fibonachi [8] +" - "
+ fibonachi [9]) ;
}}
0 Response to "Kode Fibonachi Untuk Unity #KELAS"
Post a Comment