跳至主要內容

Lab Participation 7

AI悦创原创2024年4月12日大约 7 分钟...约 2214 字

Checkpoint 1: Implement Simplified Battleship Game (2pt)

Let's do some more coding! Your task is to create a simplified version of the Battleship game (What is Battleship Game?) using object-oriented programming (OOP) principles. In this game, you'll work with a 5x5 2D list representing the game board and 3 ships placed on the board. The objective is for the player to guess the ships' locations correctly within 10 attempts.

Here's what you need to do:

Example outputs of the programs are as follows:

The following keywords and functions are banned from this task, any use of them will lead to a zero mark.

Keywords: for, in, import, global, lambda, nonlocal

Builtin functions: any, all, filter, eval, locals, exec, globals, map, open, __import__, __contains__. enumerate, sum, min, max

template code:

Checkpoint 2: Classes and Instances (1pt)

  1. Which tutorial exercise demonstrates the varied usage of methods, including those that are independent of the instance and those that depend on specific instances? Give some examples.
  2. What are the notable issues when modifying the value of an instance's attribute directly?
  3. In the Battleship game, Which methods are independent of the instance, and which ones are dependent on a specific instance?
公众号:AI悦创【二维码】

AI悦创·编程一对一

AI悦创·推出辅导班啦,包括「Python 语言辅导班、C++ 辅导班、java 辅导班、算法/数据结构辅导班、少儿编程、pygame 游戏开发、Web、Linux」,全部都是一对一教学:一对一辅导 + 一对一答疑 + 布置作业 + 项目实践等。当然,还有线下线上摄影课程、Photoshop、Premiere 一对一教学、QQ、微信在线,随时响应!微信:Jiabcdefh

C++ 信息奥赛题解,长期更新!长期招收一对一中小学信息奥赛集训,莆田、厦门地区有机会线下上门,其他地区线上。微信:Jiabcdefh

方法一:QQ

方法二:微信:Jiabcdefh

Code
Code1
通知
关于编程私教&加密文章