国产人妻人伦精品_欧美一区二区三区图_亚洲欧洲久久_日韩美女av在线免费观看

合肥生活安徽新聞合肥交通合肥房產生活服務合肥教育合肥招聘合肥旅游文化藝術合肥美食合肥地圖合肥社保合肥醫院企業服務合肥法律

CSCI1540代做、代寫C++設計編程

時間:2023-12-12  來源:合肥網hfw.cc  作者:hfw.cc 我要糾錯



CSCI1540 Fundamental Computing Using C++, Fall 2023/24
Department of Computer Science and Engineering, The Chinese University of Hong Kong
Copyright © 2023 CSE, CUHK Page 1 of 7
Assignment 6: Rush Hour
Due: 23:59, Sat 9 Dec 2023 File names: RushHour.cpp
playgame.cpp
Full marks: 100
Introduction
The objective of this assignment is to practice object-oriented programming. You will write a class
and a client program to play a sliding block puzzle game called Rush Houra
.
The game is played on a grid of size 8 × 8 with at most 10 cars on it. The cars are aligned either
vertically or horizontally in the grid and occupy two or three tiles. There is an exit hole on the right
side of the grid. The goal of the puzzle is to move the cars forward or backward (but not change
direction) so that a designated car (called Car 0) moves to the exit hole. Figure 1(a) shows an
example puzzle configuration, in which Cars 0, 1, 6, and 7 are horizontal and can move left or right,
and Cars 2, 3, 4, and 5 are vertical and can move up or down. Moving Car 1 to the right by one tile
yields the state in Figure 1(b). Continuing to move the cars carefully, you can yield the solved state as
in Figure 1(c) where Car 0 reaches the exit hole on the right.
########
#11...2#
#3..4.2#
#3004.2.
#3..4..#
#5...66#
#5.777.#
########

########
#.11..2#
#3..4.2#
#3004.2.
#3..4..#
#5...66#
#5.777.#
########
→ … →
########
#311...#
#3.....#
#3....00
#5..4.2#
#5664.2#
#7774.2#
########
(a) Initial (b) Move Car 1 (c) Solved
Figure 1: An Example Rush Hour Configuration and its Solved State
Program Specification
You shall write your program in two source files RushHour.cpp and playgame.cpp. The former is
the implementation of the class RushHour, while the latter is a client program of class RushHour
which performs the program flow. You are recommended to finish the RushHour class first before
writing the client program. When you write the RushHour class, implement the member functions
and test them individually one by one. Your two files will be graded separately, so you should not mix
the functionalities of the two files.
Class RushHour (RushHour.cpp)
You are given the interface of the RushHour class in the header file RushHour.h. You shall not
modify the contents of this header file. Descriptions of the class are given below.
a You may play Rush Hour online at: https://www.mahjongfun.com/rush-hour/
CSCI1540 Fundamental Computing Using C++, Fall 2023/24
Department of Computer Science and Engineering, The Chinese University of Hong Kong
Copyright © 2023 CSE, CUHK Page 2 of 7
class RushHour {
public:
 RushHour(const string g[]);
 bool locateCar(int car, int &row, int &col);
 int moveCar(int car, int step);
 bool isSolved();
 int getTotalSteps();
 void print();
private:
 string grid[8];
 int totalSteps;
};
Private Data Members
string grid[8];
The Rush Hour puzzle is represented by an array of string. Each element grid[𝑖] stores the
contents in row 𝑖 of the grid. E.g., for the configuration in Figure 1(a), grid[0] is “########”,
grid[1] is “#11...2#”, grid[2] is “#3..4.2#”, etc. All characters in the strings are either ‘#’
(border), ‘.’ (empty), or digits ‘0’–‘9’ (cars). All the strings are of length 8.
int totalSteps;
The total number of steps that a player has moved during puzzle play. Note that moving a car by, say,
two tiles, is counted as two steps.
Public Constructor and Member Functions
RushHour(const string g[]);
This constructor initializes the Rush Hour puzzle using the array parameter g, which contains
contents for row 1 to row 6 of the grid. (That is, g[0] is used to initialize grid[1]; g[1] is used to
initialize grid[2]; …; g[5] is used to initialize grid[6].) Note that row 0 and row 7 are not
needed in the parameter because the two rows always contain only the ‘#’ symbol. You just have to
initialize grid[0] and grid[7] as “########”. E.g., suppose g is {"#11...2#", "#3..4.2#",
"#3004.2.", "#3..4..#", "#5...66#", "#5.777.#"}. Then grid shall be initialized such
that grid[0]…grid[7] become “########”, “#11...2#”, “#3..4.2#”, “#3004.2.”,
“#3..4..#”, “#5...66#”, “#5.777.#”, and “########” respectively (that is, the configuration in
Figure 1(a)).
You can assume that:
➢ Array parameter g is always of size 6;
➢ Each string g[0], …, g[5] is always of length 8, and always contains eight symbols of either ‘#’
(border), ‘.’ (empty), or digits ‘0’–‘9’ (cars);
➢ The strings g[0], …, g[5] always start and end with the border ‘#’. An exception is on g[2] (for
grid[3]), where its last character is always the exit hole (‘.’).
➢ The cars always occupy either two or three tiles, and are always properly aligned vertically or
horizontally.
CSCI1540 Fundamental Computing Using C++, Fall 2023/24
Department of Computer Science and Engineering, The Chinese University of Hong Kong
Copyright © 2023 CSE, CUHK Page 3 of 7
You do not have to handle situations where the parameter g does not conform to these assumptions.
Remember to also initialize the data member totalSteps as 0.
bool locateCar(int car, int &row, int &col);
Finds the position of the parameter car in the puzzle. The position of a vertical car is its topmost tile.
The position of a horizontal car is its leftmost tile. The row and column indices of the found position
are assigned to the reference parameters row and col respectively, and the member function shall
return true. E.g., locating Car 2 in Figure 1(a) shall write 1 to row and 6 to col and return true,
because Car 2 appears at row 1, column 6. In case car cannot be located in the grid (e.g., there is no
Car 8 in Figure 1(a)), the member function shall not update row and col and return false.
int moveCar(int car, int step);
Performs the action of moving the parameter car by step tiles. A positive value for step means
moving down (for vertical car) or right (for horizontal car); a negative value means moving up (for
vertical car) or left (for horizontal car). E.g., in Figure 1(a), moving Car 6 left by three tiles has a step
of -3. A move is valid only if all the followings are satisfied:
➢ The parameter car exists in the grid.
➢ The parameter step is non-zero. (Moving a car by 0 tile is meaningless.)
➢ There is enough space to allow the car to move by step tiles, without hitting other cars or the
border, or going beyond the exit hole. (E.g., in Figure 1(a), Car 6 cannot move left by four tiles (-4
steps), as it would hit Car 5.)
If the move is valid, then data members grid and totalSteps shall be updated accordingly.
Otherwise, no updates to grid and totalSteps are needed. This member function shall return
either 0, 1, or 2, according to the following conditions:
Condition Return value
Move is valid 0
car does not exist in the grid or step is zero 1
Hit other cars or border or go beyond the exit hole 2
Implementation hint: First, find the position of car (with the help of locateCar()). Then
determine which one of the four cases the prospective move is: move left/right/up/down. Implement
the four cases one by one. For each case, check whether the move is valid or not. If valid, update the
car to the new position (by updating the grid contents).
bool isSolved();
Returns true if Car 0 touches the exit hole; returns false otherwise.
int getTotalSteps();
Returns the total number of steps that a player has moved the cars. That is, the value of the data
member totalSteps.
void print();
Prints out the Rush Hour puzzle and the number of steps that the player has used. The following is
an example output of print().
CSCI1540 Fundamental Computing Using C++, Fall 2023/24
Department of Computer Science and Engineering, The Chinese University of Hong Kong
Copyright © 2023 CSE, CUHK Page 4 of 7
########
#311..2#
#3....2#
#300..2.
#5..4..#
#5664..#
#7774..#
########
Steps: 10
Client Program (playgame.cpp)
Your main program is a client of the RushHour class. You create a RushHour object here and call its
member functions to implement the following program flow.
1. The program starts with prompting the user to enter six strings (separated by spaces), which are
the initial grid contents for row 1 to row 6 of the puzzle. Then create a RushHour object using
the user input. You can assume that the six strings follow the same assumptions stated in the
constructor above).
2. Prompt the user to move a car. You can assume that the user always enters two integers,
denoting the car and the steps of the prospective move respectively. (Positive step means
moving down/right; negative step means moving up/left.)
3. In case the input is not a valid move (see definition in the moveCar() member function above),
the program prints a warning message and goes back to Step 2. Otherwise, move the car
accordingly.
Note: there are two kinds of warning messages. When the car does not exist or the step is zero,
the message “Invalid car or step! Try again.” shall be printed. When the move would hit other
cars or border or go beyond the exit hole, the message “Hit! Try again.” shall be printed.
4. If the puzzle is not yet solved after the move and the total number of steps is smaller than 100,
go back to Step 2.
5. Finally, print the puzzle and either the winning message “Congrats! You finished in 𝑋 steps.”
(where 𝑋 is the number of steps used) or the losing message “Oops! You could not solve in 100
steps.”
Some Points to Note
➢ You cannot declare any global variables in all your source files (except const ones).
➢ Remember to #include "RushHour.h" in both RushHour.cpp and playgame.cpp.
➢ You can write extra functions in any source files if necessary. However, extra member functions
(instance methods), no matter private or public, are not allowed.
➢ Your RushHour class shall not contain any cin statements. All user inputs shall be done in the
client program (playgame.cpp) only.
➢ The RushHour class shall not contain any cout statements except in the print() member
function for printing the puzzle.
CSCI1540 Fundamental Computing Using C++, Fall 2023/24
Department of Computer Science and Engineering, The Chinese University of Hong Kong
Copyright © 2023 CSE, CUHK Page 5 of 7
Sample Run
In the following sample run, the blue text is user input and the other text is the program output. You
can try the provided sample program for other input. Your program output should be exactly the
same as the sample program (same text, symbols, letter case, spacings, etc.). Note that there is a
space after the ‘:’ in the program printout. More sample runs and initial grids are available in
Blackboard.
Enter initial grid: #11...2# #3..4.2# #3004.2. #3..4..# #5...66# #5.777.#
########
#11...2#
#3..4.2#
#3004.2.
#3..4..#
#5...66#
#5.777.#
########
Steps: 0
Move a car: 1 4
Hit! Try again.
Move a car: 1 1
########
#.11..2#
#3..4.2#
#3004.2.
#3..4..#
#5...66#
#5.777.#
########
Steps: 1
Move a car: 3 0
Invalid car or step! Try again.
Move a car: 3 -2
Hit! Try again.
Move a car: 8 1
Invalid car or step! Try again.
Move a car: 3 -1
########
#311..2#
#3..4.2#
#3004.2.
#...4..#
#5...66#
#5.777.#
########
Steps: 2
Move a car: 5 -1
CSCI1540 Fundamental Computing Using C++, Fall 2023/24
Department of Computer Science and Engineering, The Chinese University of Hong Kong
Copyright © 2023 CSE, CUHK Page 6 of 7
########
#311..2#
#3..4.2#
#3004.2.
#5..4..#
#5...66#
#..777.#
########
Steps: 3
Move a car: 7 -2
########
#311..2#
#3..4.2#
#3004.2.
#5..4..#
#5...66#
#777...#
########
Steps: 5
Move a car: 6 -3
########
#311..2#
#3..4.2#
#3004.2.
#5..4..#
#566...#
#777...#
########
Steps: 8
Move a car: 4 2
########
#311..2#
#3....2#
#300..2.
#5..4..#
#5664..#
#7774..#
########
Steps: 10
Move a car: 2 3
########
#311...#
#3.....#
#300....
#5..4.2#
#5664.2#
#7774.2#
########
Steps: 13
Move a car: 0 5
Hit! Try again.
Move a car: 0 4
CSCI1540 Fundamental Computing Using C++, Fall 2023/24
Department of Computer Science and Engineering, The Chinese University of Hong Kong
Copyright © 2023 CSE, CUHK Page 7 of 7
########
#311...#
#3.....#
#3....00
#5..4.2#
#5664.2#
#7774.2#
########
Steps: 17
Congrats! You finished in 17 steps.
Submission and Marking
➢ Your program file names should be RushHour.cpp and playgame.cpp. Submit the two files in
Blackboard (https://blackboard.cuhk.edu.hk/). You do not have to submit RushHour.h.
➢ Insert your name, student ID, and e-mail as comments at the beginning of all your files.
➢ Besides the above information, your program should include suitable comments as
documentation in all your files.
➢ You can submit your assignment multiple times. Only the latest submission counts.
➢ Your program should be free of compilation errors and warnings.
➢ Do NOT share your work to others and do NOT plagiarize. Those who shared their work and/or
plagiarized others work shall be penalized.
請加QQ:99515681 或郵箱:99515681@qq.com   WX:codehelp

掃一掃在手機打開當前頁
  • 上一篇:代寫CS 8編程、代做Python語言程序
  • 下一篇:COMP2396代做、代寫Tic-Tac-Toe Game設計編程
  • 無相關信息
    合肥生活資訊

    合肥圖文信息
    流體仿真外包多少錢_專業CFD分析代做_友商科技CAE仿真
    流體仿真外包多少錢_專業CFD分析代做_友商科
    CAE仿真分析代做公司 CFD流體仿真服務 管路流場仿真外包
    CAE仿真分析代做公司 CFD流體仿真服務 管路
    流體CFD仿真分析_代做咨詢服務_Fluent 仿真技術服務
    流體CFD仿真分析_代做咨詢服務_Fluent 仿真
    結構仿真分析服務_CAE代做咨詢外包_剛強度疲勞振動
    結構仿真分析服務_CAE代做咨詢外包_剛強度疲
    流體cfd仿真分析服務 7類仿真分析代做服務40個行業
    流體cfd仿真分析服務 7類仿真分析代做服務4
    超全面的拼多多電商運營技巧,多多開團助手,多多出評軟件徽y1698861
    超全面的拼多多電商運營技巧,多多開團助手
    CAE有限元仿真分析團隊,2026仿真代做咨詢服務平臺
    CAE有限元仿真分析團隊,2026仿真代做咨詢服
    釘釘簽到打卡位置修改神器,2026怎么修改定位在范圍內
    釘釘簽到打卡位置修改神器,2026怎么修改定
  • 短信驗證碼 寵物飼養 十大衛浴品牌排行 suno 豆包網頁版入口 目錄網 排行網

    關于我們 | 打賞支持 | 廣告服務 | 聯系我們 | 網站地圖 | 免責聲明 | 幫助中心 | 友情鏈接 |

    Copyright © 2025 hfw.cc Inc. All Rights Reserved. 合肥網 版權所有
    ICP備06013414號-3 公安備 42010502001045

    国产人妻人伦精品_欧美一区二区三区图_亚洲欧洲久久_日韩美女av在线免费观看
    俺也去精品视频在线观看| 亚洲国产精品一区二区第一页| 国产一区二区视频免费在线观看| 日韩高清专区| 日本香蕉视频在线观看| 在线观看欧美一区| 亚洲精品不卡| 日本一本中文字幕| 人人澡人人澡人人看欧美| 青青草精品视频在线| 黄页免费在线观看视频| 国产在线青青草| 国产精品一线二线三线| 91高清免费在线观看| 久久国产精品99久久久久久丝袜| 久久久久久久香蕉网| 久久精品视频中文字幕| 久久天天躁狠狠躁夜夜躁2014 | 久久精品国产亚洲| 国产精品久久久av久久久| 国产精品久久久久久久久久久久久久 | 热久久精品国产| 奇米影视亚洲狠狠色| 国内精品一区二区三区| 免费观看美女裸体网站| 高清不卡一区二区三区| 久久久一本精品99久久精品66| 久久精品国产理论片免费| 国产精品后入内射日本在线观看| 欧美激情伊人电影| 日本久久久网站| 美女精品国产| 91黄在线观看| 国产精品久久久久久久久影视| 一区中文字幕在线观看| 热99这里只有精品| 国产欧美日韩综合一区在线观看| 国产精品91久久久| 国产精品高潮呻吟久久av野狼| 欧美日韩国产第一页| 日韩av影视| 国产在线视频欧美| 国产脚交av在线一区二区| 国产精品免费视频一区二区| 亚洲中文字幕无码av永久| 人人干视频在线| 国产精品亚洲天堂| 日韩视频精品在线| 亚洲欧洲国产日韩精品| 精品日产一区2区三区黄免费 | 久久精品欧美视频| 一本—道久久a久久精品蜜桃| 日本精品免费观看| 国产精品一区二区三| 久久久91精品国产| 色乱码一区二区三在线看| 国产日韩精品一区二区| 国产成人精品在线播放| 亚洲成人网上| 国产狼人综合免费视频| 国产精品免费久久久久影院| 日本一区二区三区视频在线观看| 国产麻豆一区二区三区在线观看| 久久久久久久久久久久久久一区| 免费不卡欧美自拍视频| 男人天堂新网址| 日韩在线视频网| 日本久久高清视频| 久久久欧美精品| 亚洲精品免费一区二区三区| 国产啪精品视频| 欧美乱大交xxxxx| 免费国产一区| 国产精品久久久久久网站| 欧美在线视频一区| 久久精精品视频| 亚洲欧美精品| 91精品国产综合久久久久久久久| 久久五月情影视| 国内成人精品一区| 国产精品日韩二区| 欧美成人精品欧美一级乱| 日韩在线视频播放| 欧洲黄色一级视频| 久久激情视频免费观看| 欧美一级大胆视频| 久久精品91久久香蕉加勒比| 欧美在线观看一区二区三区| 久久av免费一区| 日韩精品视频在线观看视频| 久久人91精品久久久久久不卡| 亚洲精品久久久久久一区二区| 国产精品一区免费观看| 欧美久久精品一级黑人c片| 国产一区二区三区色淫影院| 久久国产精品影片| 国产乱子伦精品无码专区| 国产aaa一级片| 91免费欧美精品| 色狠狠久久av五月综合|| 国产成人精品久久亚洲高清不卡| 日本高清+成人网在线观看| 色狠狠久久aa北条麻妃| 黄www在线观看| 国产99视频精品免费视频36| 99在线免费观看视频| 丁香六月激情网| 久久国产乱子伦免费精品| 日本国产中文字幕| 久久人人爽亚洲精品天堂| 蜜桃成人在线| 亚洲一区二区在线免费观看| 国产成人精品电影| 精品1区2区| 一区二区三区观看| 久久精品日韩| 妓院一钑片免看黄大片| 欧美日韩爱爱视频| 国产高清在线一区二区| 久久精品国产精品青草色艺| 成人av免费在线看| 欧美激情视频在线免费观看 欧美视频免费一 | 久久99国产综合精品女同| 丰满爆乳一区二区三区| 午夜久久资源| 久热免费在线观看| 欧美日本韩国在线| 一本一本a久久| 国产成人极品视频| 精品一区二区中文字幕| 亚洲视频在线二区| 日韩中文有码在线视频| 国产精品揄拍一区二区| 日韩伦理一区二区三区av在线| zzijzzij亚洲日本成熟少妇| 国产欧美日韩免费| 日韩av色在线| 久久999免费视频| 国产mv久久久| 国产伦精品一区二区三区照片| 色狠狠久久av五月综合|| 国产精品久久久久久久久久久不卡 | 久久av免费一区| 免费一级特黄毛片| 无码人妻h动漫| 精品九九九九| 久久综合福利| 国产一区不卡在线观看| 全黄性性激高免费视频| 一区国产精品| 国产精品黄视频| 色偷偷91综合久久噜噜| 北条麻妃在线视频观看| 黄色国产小视频| 日产精品久久久一区二区| 九九精品在线观看| 久久久久久尹人网香蕉| 国产亚洲欧美一区二区| 欧美性视频精品| 日韩成人在线资源| 亚洲一区二区三区香蕉| 久久成人免费视频| 国产精品视频一区二区三区经| 91精品国产自产在线| 国产乱淫av片杨贵妃| 精品少妇人妻av免费久久洗澡 | 亚洲高清在线观看一区| 欧美猛交免费看| 国产精品视频一区二区三区四 | 久久久久九九九| av中文字幕av| 国产奶头好大揉着好爽视频| 好吊色欧美一区二区三区| 欧洲在线视频一区| 日本精品一区二区| 日日噜噜噜夜夜爽爽| 亚洲一区二区中文| 欧美人交a欧美精品| 国产精品沙发午睡系列| 视频在线观看99| 日韩天堂在线视频| 日韩亚洲精品视频| 久久av免费一区| 久久99导航| 久久久久久久久网| 久久久久人妻精品一区三寸 | 国产精品久久久久久久久久| 久久久久久久香蕉| 久久久久久久久久国产| 九九热只有这里有精品| 久久精品久久精品国产大片| 69av视频在线播放| 久久影院理伦片| 国产高清视频一区三区| 国产激情视频一区| 久久久久久国产精品免费免费 | 痴汉一区二区三区| 日本久久久网站| 欧美性视频精品| 国产综合av在线|