首页 > > 详细

Java辅导:CS367 Image Packets调试Java编程

Linked list,。

Goals

The goals of this assignment are to:

  • Understand, implement, and use linked chains of nodes.
  • Write classes that implement Java interfaces.
  • Gain experience working with Java references.
  • Implement exceptions and understand the difference between checked and unchecked exception.

Description

In this assignment, your goal is to build an image viewer application with cache (i.e. CacheImageApp).

Computer networks are integral to all aspects of our lives. We routinely use these networks without giving a second thought to how a web of interconnected machines successfully conveys our information and that of millions of others. For this assignment, we’ll explore how computer networks ensure successful data transmission. Specifically, this program will simulate the transmission of an image over a computer network. You’ll be coding the receiver (i.e. SingleImageReceiver) that gets information packets from a simulated network and reconstructs an image file. We’ve already coded the image file’s sender and network simulator.

To transmit an image file, it is divided into numerous small data packets that are sent across the network. The reality is that networks are complicated and not very reliable. Packets might be lost or duplicated (to make life easier, packets are not corrupted in this assignment), and if that wasn’t enough, they arrive at the receiver out of order! To address this, a sequence number is given to each packet. This simple approach can be used to determine if there are any missing or duplicate packets, and also to arrange the received packets in the correct order to properly reconstruct the file.

As the receiver, your job is to collect all these packets, remove duplicates, request any that are missing, and put them in order by sequence number so that the image can be opened without errors. For missing packets, you’ll need to request re-transmission. The packets are stored in a singly-linked list with a header node but without a tail node. The data item for each node is one packet. If you’ve done your job well, you will have reconstructed the entire file as a complete and properly sequenced chain of packets so that it can be opened by our image viewer for you to see the picture. The following figure illustrates this process.

But sometimes an image file may be very large or the network may be very slow. And you may wish to request the same image many times. As it is really time-consuming to receive and reconstruct an image in this way again and again, your program will address this issue by using a cache. In computing, a cache is hardware or software that stores data so future requests for that data can be served faster.

What you need to do is first check whether the image is already in the cache when you want to receive an image file. If the image’s linked list is already in the cache, you don’t need to receive and reconstruct it again. If the image chain is not in the cache of image linked lists, you will receive it, and store its name and linked list in the cache. The following is the structure of the cache.

Specifications

Important Classes

PacketLinkedListClass

This class stores a sequence of packets and and is used to reconstruct the image file. It implements the methods defined in ListADT interface. Note: The ListADT interface in this program extends Iterable, so your list classes must also implement methods in Java’s java.lang.Iterable interface.

Iterating over lists is done with a PacketLinkedListIterator object (See next class description). The data structure used to create its iterator is a singly-linked chain of Listnode objects, where the Listnode sent to create the Iterator is the header node. There is no tail reference.

PacketLinkedListIteratorClass

Instances of this class are used to iterate through a PacketLinkedList object. The iterator has direct access to the PacketLinkedList’s chain of nodes.

It’s constructor accepts a Listnode (that is a header node). It implements the methods defined in Java’s java.lang.Iterator interface, but it does not support the remove() operation.

SingleImageReceiver Class

Instances of the class simulate a receiver for a single image by maintaining an image buffer, which is a linked list of packets of the transmitted image file. It collects packets from our InputDriver and reconstructs and stores the image file pack⁳ ⁨⁥⁆⁥⹰⁡䍣⁳䙯䵴⡥⁵⤮††⁡⁡†⁸⁴†⁵†⁥⁥⁩⁤‭⹦⁩⵳⁩⁷⁲⁩
ⱆ⁥⁴†♲㭲†⁥‼‍⁩⁣⁨⁡⁳††⹤㰠⽡㹤ഠ੡㱤㌠⁴㵭∠䕴⵴ⴠⵦ≮㹹䔠ⵤ⵩⁥㰠⽤㌠㹮൯ੴ㰠㹥⁥†⁡⁳⁹†⁲⁴⁥♥㭴䕩⵴ⴠ⁲♩㭮⸬†⁣⁩⁡†⁣⁴†⁲†⁤‼‍⁳†⹡⁣䥫⁴⁦⁴†䕉䙰⁵⡴䕄⵶ⴠ䙣⥢⁥⁤‱†‮䤠⽔⹩㱳⼠㹥ൡ੮㱳㹹䙯⁲Ⱐ⁧†⁰⁴⁩⁲⁳㍨㉯⁷⹳⁥䅱⁥⁣ⱳ†′☠㬠⁥⁴⁸⁧⁴⁰⁩‱⸬†‬†⁵⁡⁥⁡⁴‱⁉ⱥ†⁰†⁴⁵⁴⁤⁨†⁲⸦⁲䙳⁡ⱴ※‭⁧䕴ⴵⵧ†⁥⁵†⁴⁲†⴨㍯㉮⹥
†⁳†⁲⁶†ⁱ⹡⁣䥫Ⱪ⁥⁲⁩⁩⁩⁸⁥⁴⹤†⁡⁡⁲⁴⁰⁥ⁱ⹲䙶⁥ⱹ⁌⁴⁨⁩⁲⁵†⁳ㅴ⁩†㍢づⰠ⁧♥㭩⁷⁳⁣⁥⁴⁲⹳㱰⽡㹥ഠ੡㱦㹥⁡䕣ⵣ⵭⁦⁨⁳⁴†⹯⁷䤠⁨⁦䥯䐠†⁤⁩⁶䘠⡥⤠⁹⁳⁥⁥⁹⁥⹥⁲䤠†⁥⁹⁣⁥䕮ⵯⴠ⁡⁩⁩⁩⁵⹯⁲♢㭧 ‼†⁃䙥䵡⠾⁨⥡⁧⁰⁳″⁨⁥⁣ぬ⁡††⁲䕴⵴ⴠ⁸⁳⵵⹡⁧䉥⁶⁰⁩⁩⁡⁨†⁥ⵡ⁲⁳†⁨†⹩䥩⁥⁥⁥†ⵡ‮⁲†⁵⁥⁥ⱬ⁥⁩䕯⁰ ⸠㱲⽥㹲൩੥㱶㉉㵥∠䥭ⵤ∠㹣䥨⼠㱲⼠㉨㹥ഠ੩㱭㹧䅥⁩䤠Ᵽ⁡†⁳⁣⁨ⵤ⁳⹥⁤䤠ⱥ⁩†⁩⁩⡮⁴†⁧⁳⁡⥥⹤⁌†♭㭣⁣⁩‮⁣⁌⁌†⁨♷㭹†⁲⁥䤠䑮⁡⁥†♥㬠⁣⁥⁨⁩⁤⁥⁴⁴⁩⁴⁡⸾‍⁹⁥♬㭹⁵♯㭬⁹⁲⁳⁥⁣⁳†Ⱐ⁴⁡⁦⁩⁹†♗㭧⸠☦㬻⁴⠠⁰㵩でⰠ⁴ㅨⱥ†⹩⹭ⱡ⁧㡥⤠⹵䔠ⱱ⁵⁥⁩⁴⁧䍭䤠䅴††⁉⁧†㈠†⹰㱥⽮㹭ൡ੧㱥㹭䅥⁨⁹ⱥ†♥㭥⁨⁡䥭䑭⁡⁩⁳⁴⁥⁤⁩⁨††⁩⁥⁥†⁶⡥䱰䱧⥥⹴⁨⁥⁥⁴䱯䱮䥯⁥⁥⁴⁴⁣⁨†‬†⁩⁹⁳⁤ ⸽•‭䥃䑥⁒⁳⁵䍮䥯䅬♦㭮⁴䥩⡨⤲‾⹩㱤⼽㹄൵ੰ㱬㹣‭⁄⁣⁣䥫⼯⁰㩮⹯㱲⽭㹬ഠੴ㱲㹭㱩㹮䔠⁡っ⁳⁩⁴㩰ば⹡⁴⁣䥥†㴨⁨ぴ⹨⁡䱭⁥⁵
⹥⸠⹡⁲䕥†ね⁡††⁰㩡⁣㠯⹰‼†䤼⁥㵣⁥㡥⹴⁳䰠⁨⁳⹥⹤⸠⁡䕮び†⁲⁴⁩㨍 㡩⸾⁤⁳䤠⁣㵫⁥㡴⸠䱯†⁴⹴⹨⹥†䕯ち⁲⁳⁡㨾‍《‼⁲䕥⹩⁶㱥⽲㹤㱳⼠㹲൥ਠ㱡㹥⁰⁴⁣⁴⁰⁳⁨⁩†⹩㱶⽥㹡൮੤㰠㹩⁤⁨⁲⁡‮⁳⁴䤬䐠⁤⹥⁥䑰⁳  ⁍⁩⁡⁥⁩⸠㱐⽡㹫൥ੴ㱳㹨ളਾ‍ ‼⁰㰾㹣⁣っ⁡⵳⁩ㅯ㩮⁡⁨⹴㱨⽲㹧൨ਠ⁡†⁥㱴㹲⁴㉨⁩⵳†㍡㩳⁳⁴⁲※†⁷㱴⽨㹥ഠ੡⁲⁥†⁡㱮㹭†㑰⁡ⵣ㙥㩴⁳†⁩††㱓⽴㹡൭੩⁧†⁎㱯㹦㜠⁐ⵡ⁣㡫㩥⁴⁥⁡⁥⁴Ᵽ⁩⁣⁨⁣⁥⁩⁰⁳⁲⁵⁤⸀㰀⼀㸀ഀ਀㰀⼀㸀ഀ਀㰀㈀ 㴀∀ⴀ䘀∀㸀 䘀㰀⼀㈀㸀ഀ਀㰀㸀        䌀䤀䄀     ☀㬀  ⸀㰀⼀㸀ഀ਀㰀㸀ഀ਀    㰀㸀䤀    ☀㬀 ☀㬀Ⰰ   ⸀㰀⼀㸀ഀ਀    㰀㸀䤀       Ⰰ  ഀ਀    㰀㸀ഀ਀        㰀㸀 䤀         ⸀ 䤀      Ⰰ    䰀䰀   ⸀ Ⰰ  䤀              ⸀㰀⼀㸀ഀ਀        㰀㸀 䤀                㬀 Ⰰ      Ⰰ      ⸀ ⠀                          ⸀⤀㌀⸀          㰀⼀㸀ഀ਀        㰀㸀䤀       Ⰰ  㰀⼀㸀ഀ਀    㰀⼀㸀ഀ਀    㰀⼀㸀ഀ਀    㰀㸀    ⠀ ⤀㰀⼀㸀ഀ਀    㰀㸀           ⸀㰀⼀㸀ഀ਀㰀⼀㸀

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!