# Simple is best ... !

## Can life be like a program?

.:: Can life be like a program? ::.
```Program Life Basics;  // Can life be like a program?  Let's see!
Uses
LifeLib;
Var
Food, Sleep, Water As Needs;
Happiness As LifeStrength;
Love As SomethingNeeded(4);
Age, Death As Integer;
Junction Person
Begin
Health As Status;
End;
Const
GotoSchool;
Work;
StayInHome;

Begin

Death := Random(100); // We all know that the death is random.
Happiness := 2 + Random(5); // Happiness is random too.

Do

// Should I go to school, to work or stay in home?
If (Age < 18) Then
GotoSchool;
Else If (Age < 50)
GotoWork;
Else
StayInHome;
End;

// Let's try to survive...!
If Not Food Then
Person.Health := False
Happiness := Happiness - 2
Else
Happiness := Happiness + 5
End;
If Not Water Then
Person.Health = False
Happiness := Happiness - 2
Else
Happiness := Happiness + 5
End;
If Not Sleep Then
Person.Health := False
Happiness := Happiness - 2
Else
Happiness := Happiness + 5
End;

// Let's put some love in the game.

Select Case (Love)
0 : Happiness := Happiness -  20; Break;
1 : Happiness := Happiness -  10; Break;
2 : Break;
3 : Happiness := Happiness + 10; Break;
4 : Happiness := Happiness + 15; Break;
End Case;

// Happy?
If  (Happiness < -10) Then
Death := 0                    // Suicide...
Else If (Happiness < 3) Then
Person.Health := False    // Get Sick...
Else If (Happiness > 80) Then
Death := Death + 1         // Live longer!
Happiness := Happiness - 20
End;

// Am I sick?
If Not Person.Health Then
Hospital
End;

// Wow, time is going too fast!! A year has passed.
Age := Age + 1

While (Age <= Death);

// Oops... Game Over.
Write('Memento Mori...');
Write('Game Over');

End.

Procedure Hospital
Var

Begin

// Can I be saved?
If (Methods = Good) Then
Happiness := Happiness + 2
Death := Death - 1
Else If (Methods = Bad) Then
Happiness = Happiness - 2
Death := Death - 5
End;

End;
```
Đoạn code này nói về cuộc đời của một con người đến khi chết ...!

Liệu ... cuộc sống có giống 1 chương trình?
Không! Cuộc sống của mình đang và sẽ không đơn giản như đoạn code chưa đến 200 dòng này!

Unregistered user Sunday, March 15, 2009 2:43:53 PM

haohao writes: anh Tuấn tự viết hay copy paste ở đâu mà nhiều bài hay thế ^^.Hơi hâm mộ đó :d

Phạm Minh Tuấntuanpm Sunday, March 15, 2009 2:49:56 PM

Hảo xu cù đấy à ^^
Copy, paste hay tự viết thì quan trọng gì.
Quan trọng là làm sao để thể hiện ra cho mọi người cảm thấy hay thôi

Rearrear Sunday, March 22, 2009 5:46:04 AM

Sainewsai Tuesday, March 31, 2009 4:25:37 AM

// Let's put some love in the game.

Select Case (Love)
0 : Happiness := Happiness - 20; Break;
1 : Happiness := Happiness - 10; Break;
2 : Break;
3 : Happiness := Happiness + 10; Break;
4 : Happiness := Happiness + 15; Break;
End Case;

đoạn này hình như còn thiếu ?

Phạm Minh Tuấntuanpm Tuesday, March 31, 2009 12:53:02 PM

phiên phiến thôi, chỉ là tượng trưng thôi mà

Unregistered user Tuesday, April 7, 2009 2:40:46 AM

Anonymous writes: có ai chạy thử, xem nó ra cái gì nhỉ? hihi :D

### Write a comment

New comments have been disabled for this post.

December 2013
S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31