COMP2221编程辅导、java程序调试、讲解java程序 讲解SPSS|辅导Web开发

- 首页 >> Matlab编程
COMP2221 Coursework 1 1
School of Computing, University of Leeds
COMP2221
Networks
Coursework 1: InetAddress and the IPv4 hierarchy
If you have any queries about this coursework, visit the Microsoft Teams page for this module. If
your query is not resolved by previous answers, post a new message.
Learning objectives
• Use of the java.net.InetAddress class.
• Demonstrate understanding of the hierarchy in the IPv4 address scheme.
This item of coursework is worth 15% of the final module grade.
Task
Add to the empty class Coursework1, defined in the provided file Coursework1.java, to read in
hostnames from the command line, and perform one of the following actions:
• If exactly one hostname is given, your code should convert the hostname to an instance of
InetAddress, and print both the hostname and the IP address to the terminal. It should
also determine if the IP address is IPv4 or IPv6, and print a message explicitly stating that
the address is IPv4, or that it is IPv6.
• Alternatively, if exactly two hostnames are entered, your code should instead first test they
are both valid IPv4 addresses, and return an error message if not. If they are both IPv4, your
code should output the highest levels of the hierarchy shared by them both. For instance,
if the two hostnames resolve to 129.11.1.17 and 129.11.2.17, your code should output
129.11.*.* (not 129.11.*.17!) Only whole bytes need be considered, you do not need to
consider individual bits as in CIDR. If there are no levels in the hierarchy shared by both
addresses, your code should return *.*.*.*, and if both addresses are the same your code
should output the common full IP address.
The file Coursework1.java is available from Minerva. You should extend and modify the class
definition in this file to satisfy the requirements. If you decide to create additional files, be careful
to follow the submission instructions.
COMP2221 Coursework 1 2
Your code should output no more information than that stated above. There should be no
interaction with the user other than via command line arguments. In particular, your code should
not use a keyboard scanner.
At no point should your code use the InetAddress methods getAllByName() or isReachable().
Your code should adhere to the coding standards described in the file JavaCodingStandards.pdf
on Minerva.
Guidance
Some methods of InetAddress were covered in Lecture 5; the full specification can be easily found
online1. Example code using InetAddress was provided at the start of Lecture 6. You may also
like to look at the book Java Network Programming by Harold mentioned in Lecture 1.
Marks
3 marks : Correct output of the required information for a single hostname.
6 marks : Correct output of shared hierarchy for a pair of IPv4 addresses.
6 marks : Well structured and commented code with meaningful error messages. Adherence
to the provided Java coding standard.
Total: 15
Submission
If you submit a single file, it should be called Coursework1.java and uploaded to Minerva.
If your solution is split between multiple files, they should all be placed in the same directory. To
submit, cd to that directory and delete all extraneous files (.class, any IDE-related files etc.),
then create an archive .tar.gz file:
tar cvzf cwk1.tar.gz *
This will create the file cwk1.tar.gz that you should upload to Minerva.
The following sequence of steps will be performed when we assess your submission:
1. Unarchive the submission if it ended .tar.gz.
2. Compile all files with javac *.java
3. Execute your solution, e.g. java Coursework1 leeds.ac.uk www.comp.leeds.ac.uk
Your submission must work when this sequence is followed on a School machine, or
you will lose marks. This means that you should not have lines like ‘package ...’ in your
1e.g. https://docs.oracle.com/javase/7/docs/api/java/net/InetAddress.html
COMP2221 Coursework 1 3
submission, as this causes compilation to fail on a School machine. You should also ensure the
only input from the user is via command line arguments as above.
Disclaimer
This is intended as an individual piece of work and, while discussion of the work is
encouraged, what you submit should be entirely your own work. Code similarity tools
will be used to check for collusion, and online source code sites will be checked. The
standard late penalty of 5% per day applies for work submitted after the deadline.

站长地图