java入門最後一章 簡易撲克牌比較大小

johnchou發表於2021-09-09

package com.practice.zhipai;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class PracticeZhiPai {
public List list;
public String tempStr;
public List listUser;
public List user1List;//使用者1的手牌
public List user2List;//使用者2的手牌
public void createList(){
list = new ArrayList();

    for (int i = 0; i ();
    System.out.println("-----------建立玩家--------------");
    Scanner scan = new Scanner(System.in);
    for (int i = 0; i ();
    user2List = new ArrayList();

    user1List.add(list.get(0));
    user2List.add(list.get(1));
    user1List.add(list.get(2));
    user2List.add(list.get(3));
    System.out.println("-----------發牌結束--------------");
}
public void comparePai(){
    String user1Max;
    String user2Max;
    PracticeZhiPai pz = new PracticeZhiPai();
    //比較user1手牌哪個大
    //result=0 相等  result=1 a > b  result=-1 a  b  result=-1 a  u2) {
        return 1;
    }
    else if (u1 

}

class User.java
package com.practice.zhipai;

public class User {
public User(String id,String name) {
// TODO Auto-generated constructor stub
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private String id;
private String name;
}

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4422/viewspace-2799254/,如需轉載,請註明出處,否則將追究法律責任。

相關文章