Java代写|Assignment 2 Dynamic and Duck Typing


The purpose of this assignment is to offer you a first-hand experience with Python, which supports
the object-oriented design and programming paradigm. Our main focuses are Dynamic Typing
and Duck Typing.

The assignment consists of two main parts. First, you need to implement the rules of a single
player game named Strange Planet in Python to brush up on your Python skills based on the given
Java implementation. Second, we will extend the game and you need to implement more classes
for the game in both Python and Java. In the report, you need to demonstrate the flexibility
of Dynamic Typing and Duck Typing. All Python implementations in this assignment should be
built using Python 3.8, and all Java implementations should be built using OpenJDK (Open Java
Development Kit).

Because of a wrong operation, your spacecraft crash-landed on are fell to an unknown planet in
space, and you get lost wondering around. The planet is full of dangers and unknown creatures.

Try to find your way to your spaceship and get back to the Earth again. This is a programming
exercise for you to get familiar with Python, which is a dynamically typed language. In this task,
you have to strictly follow our proposed object-oriented design and the game rules for Strange
Planet stated in this section. You have to follow the prototypes of the given functions exactly.

The Java implementation of the game is also given to you for reference. Another purpose of this
exercise is for you to appreciate our object-oriented design. Think about how you would design
the software and compare it to our design. You need to implement this game in Python.

Before you can build and run the Java program we provide, you may have to prepare your develop
ment environment first. We will provide a virtual machine containing everything you need in the
development. If you prefer programming on your machine, please follow the instructions below to
install the development kits and some necessary packages. If you cannot be bothered to configure
all these things, please use our virtual machine instead.

1. Build Tools. We provide a Makefile so that you can easily build the Java application via a
make command. On an Ubuntu machine with root privilege, install build tools by executing
the following command in the terminal

sudo apt-get install build-essential

On macOS, if the make command is not found, you should install the build tools via XCode.

On Windows, you should consider downloading an IDE and configuring it by yourself, too.

2. Java Development Kit (JDK). To build the Java source files, you have to install the
JDK first. There are different JDKs available for a variety of platforms. To build this Java
application, feel free to install any kind of JDK, like OpenJDK, Oracle JDK, IBM Java SDK,
Apache Harmony, etc. Please refer to their official websites for the installation guide in detail.

We recommend you to install the open-source OpenJDK. On a Ubuntu machine with root
privilege, open your terminal and execute the following command to find all available Open
JDK versions.

apt search ^openjdk-[0-9]*-jdk$

Install any version you like via the following commands. Replace <version> with specific
version number. For example, you can install any one of openjdk-8-jdk, openjdk-11-jdk,
openjdk-13-jdk and openjdk-14-jdk on Ubuntu 20.04 LTS.

sudo apt-get update
# Replace <version> with a specific version number.
# For example, install openjdk-14-jdk on Ubuntu 20.04 LTS.
sudo apt-get install openjdk-<version>-jdk

After executing this command in the terminal, you should have already installed OpenJDK
correctly. Check the Java version and Java compiler version by java –version and javac
–version. You will get a similar output as follows if everything goes fine:

$ java –version
OpenJDK version “14.0.2” 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 14.0.2+12-Ubuntu-120.04, mixed mode,
$ javac –version
javac 14.0.2

Now you have successfully installed the JDK. Similarly, on any MacOS machine, simply open
your terminal and execute the following command:

# Replace <version> with a specific version number.
brew cask install adoptopenjdk<version>

On Windows, you may have to refer to the official websites for the installation guide in detail.

You may also need a powerful IDE, e.g. Eclipse, to build and run Java applications.

Again, if you find it tedious to set up the environment on your machine, use our Ubuntu virtual
machine instead. Everything mentioned above in this section will be pre-installed so that you do
not need to worry about wasting time on environment preparation.