Freitag, 31. Oktober 2008

Savannah.nongnu.org

Savannah.nongnu.org

Savannah.nongnu.org is a central point for development, maintenance and distribution of Free Software that runs on free operating systems.




Donnerstag, 30. Oktober 2008

Java Hearts Remarks5

EE3206/EE5805 Java Programming and Applications

There is a PlayerInfo class which holds 4 players in an ArrayList.
Each Player in turn contains an ArrayList to hold 13 cards.

swap3card() to swap 3 cards to a neighbor player.
sortcard() to sort the card in the ArrayList.



Montag, 27. Oktober 2008

Frege-算術基礎

Frege——算術基礎

Die Grundlagen der Arithmetik

(The Foundations of Arithmetic)

"Are the laws of arithmetic synthetic a priori or analytic?"

http://www.china-pub.com/722567


java interface wiki

EE3206/EE5805 Java Programming and Applications

From Savitch's Absolute Java (2 ed. 2006), p.711-713, " An inteface is a type that can be satisfied by any class that implemetns the interface."

"An interface is a type. This allows you to write a method with a parameter of an interface type, ... and that parameter will accept as an argument any class you later define that implements the interface."



Samstag, 25. Oktober 2008

F S LCM-2008

predicted states and actions taken in logic..

on what condition will collective action taken?

To forecast the state..

action is taken on the same state...predefined in logic--LCM



Donnerstag, 23. Oktober 2008

java interface

EE3206 / EE5805 Java Programming and Applications

interface inheritance

In the java textbook, Liang(2009), p.397, "You can use an interface as a data type for a variable, as the result of casting and so on."

"You can now use the Edible interface to specify whether an object is edible.

The relationship between the class and the interface is known as interface inheritance.

Since interface inheritance and class inheritance are essentially the SAME, we will simply refer to both as inheritance. "

eg:
...
if (objects[i] instanceof Edible)
System.out.println(( (Edible) objects[i] ).howToEat() );




Freitag, 17. Oktober 2008

SF001:人們等知更鳥報春時,春天已經結束了

罕 有 開 金 口 股 神 自 掏 腰 包 買 股



  (星島日報報道)股神巴菲特投資取態對全球舉足輕重,這位價值投資翹楚,一向看重股票長遠投資價值,近日在全球金融海嘯下,他認為股票投資價值漸顯,一向少於公開場合談及對股市看法的他,在《紐約時報》撰文,表示會把自己私人的資金投進美股,若美股價值持續吸引,更會百分百持有美股。以下為他在《紐約時報》全文。

  目前金融世界,包括美國以及海外都亂成一鍋粥。而金融市場的問題更擴散至整體經濟,情況一發不可收拾。短期而言,失業將會上升,商業活動搖搖欲墜,新聞頭條繼續駭人。

  正因如此……我現在已出手吸納美股。我是用個人投資戶口買入美股的,而之前這個戶口除了美國國庫債券外甚麼都沒有。(上述種種與我在巴郡的投資沒有關係,我在這家公司的投資全部用於慈善)假如美股股價持續處於吸引的水平,我在巴郡以外的淨資產很快會百分百成為美股。

  為甚麼我會這樣做?

  本人有一條很簡單的買股原則:在眾人貪婪時你要恐懼,當眾人恐懼時你就要貪婪成性。可以很肯定的說,現在恐懼正在擴散,就算是投資老手亦復如此。是的,投資者應規避高槓桿投資和市場競爭力薄弱的公司,但對為數眾多質素良好公司的長期前景感到恐慌,實在沒頭沒腦。目前很多優質公司的盈利表現的確遇到阻滯,但它們以往也經常如此,大部分的公司在未來五年、十年以至二十年仍然陸續會有新的盈利。

  首先要弄清楚一件事:我不能預測股市的短期變化。我也不知道究竟股價在一個月後或一年後會升抑或跌。不過,在市場氣氛或者經濟全面恢復之前,股市有機會上升或者大升。就好像你守候的知更鳥出現時,但春天已差不多完結了。(註:知更鳥是春天的象徵)

  再看看一點歷史:在大蕭條的時候,杜指在一九三二年七月八日見底,跌至四十一點。不過,當時經濟環境仍然持續轉壞,直至羅斯福在一九三三年三月上任時為止,期間股市已經由低位反彈了三成。或者再看看第二次世界大戰早期的情況,當美國在歐洲以及太平洋情況不妙之時,股市已經在一九四二年四月見底,比起盟軍扭轉局勢為早。在一九八○年代初期,最佳入市時機就是通脹肆虐以及經濟在谷底之時。簡單來說,壞消息就是投資者的最好朋友,讓你可以用折讓價買入美國(公司)的未來。

  長期來說,美國股票市場的消息將會是正面的。在二十世紀,美國曾經忍受兩次世界大戰及其他傷痛又昂貴的軍事衝突;大蕭條、以及十多次的衰退及金融恐慌;石油危機、流感疫症,以及總統不體面地辭職。不過,杜指多年來仍能由六十六點升至一萬一千四百九十七點。

  你或許會認為,在如此一個有特高收益的世紀,投資者不可能損失金錢,但卻有一些投資者的確損手了。那些倒楣的人只會在感到安心時購入股份,但在報章標題令他們不安時着手沽售股份。

  今天,人們會因持有現金而感到安心,但他們不應如此,因他們正選擇一個長遠只得可怕回報的資產,那些現金資產實際上不但沒有回報,而且更在貶值。政府為紓緩現時危機而作出的政策,將會證明是引致通貨膨脹的,會加速現金實質價值下跌。

  幾乎可以肯定,下個十年股票的表現會在很大程度上好於現金。目前那些執於投資現金的人應該懂得即時收手。與其坐以待斃等待股市利好消息,不如主動出擊,勿忘冰球皇帝Wayne Gretzky說過的,迎擊冰球即將出沒的地方,而不是它已經所在之處。

  我不喜歡對股市表示意見,我亦一再強調,我不知道股市短期會如何,可是,我會依據一家開設在空置銀行大廈裏的餐廳的廣告所示:你的錢在那裏,你的胃口就在那裏。今天,我的錢及胃口都在股票上。
2008-10-18

「 壞 消 息 是 投 資 者 的 最 佳 朋 友 , 因 這 時 是 執 平 貨 的 良 機。 」


Mittwoch, 15. Oktober 2008

Samstag, 4. Oktober 2008

Java Hearts Remarks4

EE3206/EE5805 Java Programming and Application

Java Hearts Game Project Remarks4

The following notes are summarized from David Eck 's Introduction to Programming Using Java, Chap 5.4:

http://math.hws.edu/javanotes/index.html


1. For the Hearts Game, we need a standard deck of playing cards. Each player gets a hand of cards.

2. The Deck is shuffled and Cards are dealt one at a time from the Deck and added to the player's hand.

3. The Card classs has instance variable, suit and value.

4.The Deck class has shuffle() and dealCard().

5. The Hand class has addCard() and removeCard()

6. A Deck obect has 52 cards in standard order when created. Activate shuffle() to randomize the card.

Activate dealCard() to get the next card from the deck. The return type is card.


7.Hand Class. It has no cards when first created. Activate addCard() to add a card to the hand.

Specify the Card object for which card is added. Activate removeCard() to specify which card to remove.


8. Card Class. Use new Card(value, suit) to create a card object. There are four suits, eg, Card.SPADES.
Use enum type to specify.

In the Hearts game, Ace is the largest while 2 is the smallest card. Modify the code.

9. In text mode, 2 helper methods, getValueAsString() and getSuitAsString() for toString() .

Java Hearts Remarks3

EE3206/EE5805 Java Programming and Applications

Java Hearts Project Remarks3

In desgining the java Hearts game project, Eck's book is a very good reference. See Chap 5.4, 6 and 12.

We need 3 classes: Card, Hand and Deck

1. How to randomize,shuffle cards?

2. For the swap direction , "x mod 4 =0" to decide the direction of swapping the 3 cards


http://math.hws.edu/javanotes/index.html



Java Hearts Remarks2

EE3206/EE805 Java Programming and Applications

The Java Hearts game project: Remarks 2


There is a card demo program on how to drag card UNDER another while the order and layer of the card remain the SAME.

Card images can be obtained from the textbook : Liang's Introduction to Java programming 7/e website. see chap 13 exercise,


http://www.leepoint.net/notes-java/examples/graphics/cardDemo/cardDemo.html

Donnerstag, 2. Oktober 2008

Java Hearts Remarks1

EE3206/EE5805 Java Porgramming and Applications

How to draw cards on the JPanel?

1. Whenever a component is displayed, the jvm automatically creates a Graphics object for the component on the native platform.

eg Graphics graphics = jpanelcanvas.getGraphics();

2. In order to draw things on a component eg JPanel
consistently, you need to declare a class that
extends a Swing GUI component class an overrides
its paintComponent method to specify what to draw

3. ImageIcon imageicon = new ImageIcon("CardImg/36.png");
Image qimage = imageicon.getImage();
g.drawImage(qimage, 40, 40, 72, 96, this);

////////////////////////////////////////////////////

import javax.swing.*;
import java.awt.*;
import java.awt.Graphics;


public class DrawQueen extends JFrame
{
// paint a quueen card image
//In order to draw things on a component eg JPanel
// consistently, you need to declare a class that
// extends a Swing GUI component class an overrides
//its paintComponent method to specify what to draw


public DrawQueen()
{
add (new DrawPanel() );
}

public static void main (String[] args)
{
DrawQueen frame = new DrawQueen();

frame.setTitle("Draw a Queen on a JPanel component");
frame.setSize(500,400);
frame.setLocationRelativeTo(null); //centre the frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}

}



class DrawPanel extends JPanel
{

ImageIcon imageicon = new ImageIcon("CardImg/36.png");
ImageIcon imageicon2 = new ImageIcon("CardImg/35.png");
ImageIcon imageicon3 = new ImageIcon("CardImg/12.png");
ImageIcon imageicon4 = new ImageIcon("CardImg/13.png");

Image qimage = imageicon.getImage();
Image rimage = imageicon2.getImage();
Image simage = imageicon3.getImage();
Image timage = imageicon4.getImage();

protected void paintComponent(Graphics g)
{
super.paintComponent(g);
g.drawLine(0,0,50,50);
g.drawString("Player 1", 0, 40);

if (qimage != null )
{
g.drawImage(qimage, 40, 40, 72, 96, this);
g.drawImage(rimage, 60, 40, 72, 96, this);
g.drawImage(simage, 80, 40, 72, 96, this);
g.drawImage(timage, 100, 40, 72, 96, this);
}

}
}