亚洲AV乱码一区二区三区女同,欧洲在线免费高清在线a,中文字幕丝袜四区,老少配老妇熟女中文高清

<s id="38axe"><nobr id="38axe"></nobr></s><abbr id="38axe"><u id="38axe"></u></abbr>

<sup id="38axe"></sup>
    <acronym id="38axe"></acronym>
  • <s id="38axe"><abbr id="38axe"><ins id="38axe"></ins></abbr></s>
    
    
        <s id="38axe"></s>

        2021下半年軟件設(shè)計師下午真題及答案解析(六)

        軟件設(shè)計師 責(zé)任編輯:胡媛 2021-11-08

        添加老師微信

        備考咨詢

        加我微信

        摘要:希賽小編在考后為大家整理了2021下半年軟件設(shè)計師下午真題及答案解析(六),希望對考生估分會有幫助。

        試題六(共15分)

        閱讀下列說明和Java代碼,將應(yīng)填入(n)處的字句寫在題紙的對應(yīng)欄內(nèi)。

        【說明】

        享元(flyweight)模式主要用于減少創(chuàng)建對象的數(shù)量,以低內(nèi)存占用,提高性能。現(xiàn)要開發(fā)一個網(wǎng)絡(luò)圍棋程序允許多個玩家聯(lián)機(jī)下棋。由于只有一臺服務(wù)器,為節(jié)內(nèi)存空間,采用享元模式實現(xiàn)該程序,得到如圖6-1所的類圖。

        【Java代碼】

        import java.util.*:

        enum PieceColor {BLACK,WHITE}//棋子顏色

        class PiecePos{//棋子位置

        private intx;

        private int y:

        pubic PiecePos(int a,int b){x=a;y=b;}

        public int getX0{retun x;}

        public int getYO{return y;}

        }

        abstract class Piece{//棋子定義

        protected PieceColor m_color;//顏色

        protected Piecemopos m_pos;//位置

        public Piece(PieceColor,color PiecePos

        pos){m color=color;

        {:sod=sod u

        (1);

        }

        class BlackPiece extends Piece{

        public BlackPiece(PieceColor

        color,PiecePos pos){super(color,pos);}

        public void drawO{

        System out println("draw a black

        piece");}

        }

        class WhitePiece extends Piece{

        public WhitePiece(PieceColor

        color,PiecePos pos){super(c

        olor,pos):}

        public void draw0{

        System.out.println("draw a white

        piece");

        }

        {

        class PieceBoard{

        //棋盤上已有的棋子

        private static final

        ArrayList<(2)>m_arrayPiece=new Arra

        yList

        private String m_blackName;//黑方名稱

        private String m_whiteName;//白方名稱

        public PieceBoard(String black,String

        white){

        m_blackName=black;m_whiteName=white;

        }

        //一步棋,在棋盤上放一顆棋子

        public void SetePiece(PieceColor

        color,PiecePos pos){

        (3)piece=null;

        if(color==PieceColor.BLACK)(//放黑子

        piece=new BlackPiece(color,pos);//獲取一顆黑子

        System.out.println(m_blackName+"在位置("+pos.getX0)

        +","+pos.getYO+")");

        (4):

        {

        else{//放白子

        piece=new WhitePiece(color,pos);//獲取一顆白子

        System.out.println(m whiteName+"在位置("+pos.getX0)+

        ","+pos.getYO+")");

        (5):

        }

        m_arrayPiece.add(piece);

        }

        }

        溫馨提示:因考試政策、內(nèi)容不斷變化與調(diào)整,本網(wǎng)站提供的以上信息僅供參考,如有異議,請考生以權(quán)威部門公布的內(nèi)容為準(zhǔn)!

        軟考備考資料免費領(lǐng)取

        去領(lǐng)取

        !
        咨詢在線老師!