$30
1. Aims
Practice applying a systematic approach to object-oriented design process
Gain experience in implementing an object-oriented program with multiple interacting classes Gain hands on experience with Java libraries
2.Preamble and Problem
So much of today's technology uses Global Positioning System (GPS) information. For example, tagging photographs with their location, guiding drivers with car navigation systems, and even missile control systems. There are currently 31active GPS satellites (a of the time of writing ths) orbiting the Earth all together providing near-constant GPS coverage.
In the far future, society has become advanced to the point where they have begun to occupy a series of moons and asterods around the panet Jupiter. Individuals rely on satellites for all their communication desires. Three major satellites exist around Jupiter.
This assessment aims to provide you with design experience for a non-trivial system. You will be architecting and modelling how these multiple satellites will communicate and function with various devices. The form of communication that you will be simulating is a simplified version of the modern internet, simply just file transfer. You can either upload a file to a satellite from a device, download a file from a satellite to a device, or send a file from a satellite to a satellite.
Your solution should adopt an Object-Oriented approach that utilises concepts such as abstraction, encapsuation, compostion, and inheritance, as taught in lectures.
A simple example
Let’s assume initially there is a Standard Satellite at height approximately 80,0km above the centre of Jupiter and a θ =821degrees degrees
(anticlockwise). In addition there are 3devices;DeviceA, DeviceB, and DeviceC. DeviceA and DeviceC are handheld devices, whereas DeviceB is a desktop device.
In this system, the satellite can talk to device A and device A can talk to the satellite (communication is done by sendng fies) snce they are n range of each other. SatelliteA however cannot talk to DeviceB (and DeviceB cannot talk to SatelliteA) because Standard Satellite s have
restrictions on what devices they can talk to (discussed in more detail later). Finally SatelliteA cannot connect to DeviceC because it's not in visible sight range. The red line in the image highlights this.
Devices are static and will not move, but satellites can! Satellites move based on a constant linear veocity, in this case Standard Satellites have a linear velocity of 2,50km per minute (or 2,50,0 metres). From this, we can calculate its angular velocity based on its height (which is the
radius from the center of Jupiter). For example, after 01mnutes it would have moved a otal of 2 , 5 0 0 / 8 0 , 0 0 0 * 1 0 mins = 0 . 0 3 1 2 5 * 1 0 =
0 . 3 1 2 5 radians ~ = 1 8 degrees (note that we don't have to account for the fact they are measured in k m here since the extra 1 0 ^ 3 component will cancel out). This means our new position is 1 8 + 1 2 8 which is approximately 1 4 5 - 1 4 6 degrees .
Eventually after moving for a couple more minutes it will get out of range of the devices A and B
Secondly, we need to look at interaction between satellites and devices. They can communicate through the transfer of files. Files can be transferred between satellites/devices and other satellites (files can not be directly sent from device to device).
To begin let's create a new file on a device. Clicking on DeviceA and pressing Create File as shown below we can create a file
Once created files can't be modified/deleted, furthermore every filename has to be unique. Creating a file called Hello World! with it's content also being Hello World! we can view it by going to the device again and clicking Open File as shown below.
We can then send this file to our satellite by just clicking on the device ensuring the file and satellite are seected as below then clicking Send File .
If we then try to open the file on the satellite we notice that it is empty and says 0/12for ts size. This is because files transfers aren't instant, they
are based on the bandwidth of the satellite. Standard Satellites are relatively slow, so they will take 21mnutes to send ths file since they only send at 1byte per minute. If we let it run for at least 21mnutes and look again we wil see the file has finished sending.
We could then continue this by running the simulation a little longer and letting the satellite orbit around to DeviceC and then sendng the fie down to DeviceC.
Simulation
A simulation is an incremental process starting with an initial world state, say WorldState_0. W e add a specified time interval of 1minute and calculate the new positions of all the satellites after the minute. We then go and update all the connections accordingly to derive the next world state WorldState_01. Similarly, we derive W orldState_02from W orldState_01, W orldState_03from W orldState_02, and so on. This act of feeding a world state into the next forms a sort of state machine. An similar example of this is Conway's Game of Life.
WorldState_00 - > WorldState_01 - > WorldState_02 - > ...
In our case our simulation runs at an accuracy of 1minute and each state transition will take only 1mnute.
3. Requirements 2'
Fi NOTE: This pr oblem will not require any heavy use of mathematics, you will be provided with a library that will perform all the calculations for you.
There are three tasks set out for you.
1 . Model the problem, including:
Modelling the satellites/devices.
Satellites/Devices must be able to be added/removed at runtime (with various consequences)
Most importantly a series of 'queries' about the current world state such as what devices currenty exist
2 . Allow satellites/devices to send files to other satellites.
3 . Implement a special device and a special satellite with unique properties.
Assumptions
In this problem, we are going to have to make some assumptions. Let us assume that
Satellites move around at a constant linear velocity regardless of their distance from the planet (their angular veocity woud change based upon the distance, though).
The model is two dimensional
Objects do not rotate on their axis and simple planatary orbit is the only 'rotation' that is alowed in the system.
Jupiter has a radius of 6 9 , 9 1 1 kilometres.
For the sake of consistency:
All distances are in kilometres ( 1 k m = 1 , 0 0 0 m ).
Angular velocity is in radians per minute (not per second). Linear velocity is in kilometres per minute (not per second).
Devices 9
There are three types of devices available. Each device has a maximum range from which it can connect to satellites.
HandheldDevice – phones, GPS devices, tablets.
Handhelds have a range of only 50,0kilometres (50,0,0metres) LaptopDevice – laptop computers.
Laptops have a range of only 100kilomeres (10,00metres) DesktopDevice – desktop computers and servers. Desktops have a range of only 20,0kilomeres (20,00metres)
Files
Devices can store an infinite number of files and can upload/download files from satellites. Files are represented simpy by just a string representing their content and a filename representing their name.
All files can be presumed to purely consist of alphanumeric characters or spaces (i.e. a-z, A-Z, 0-9, or spaces) and filenames can be presumed to to be unique (i.e. if two files have the same filename they will have the same content). Furthermore, since we are dealing with such a simple subset, 1 character is equivalent to 1byte. We will often refer to the size of files in terms of bytes, and the file size only relates to the content of the fie (and not the filename).
To send files the target needs to be within the range of the source BUT the source does not have to be within the range of the target. For example if a HandheldDevice (range 5 0 , 0 0 0 k m ) is 1 0 0 , 0 0 0 k m away from a StandardSatellite (range 1 5 0 , 0 0 0 k m ) it can't send files to the
satellite but it can receive files from the satellite. If the device is 1 6 0 , 0 0 0 k m away from the satellite neither can interact with each other. Satellites can also send files to other satellites but devices can not send files to other devices.
Files do not send instantly however, and are limited by the bandwidth of the satellites. Satellites will always ensure fairness and will evenly allocate bandwidth to all currently uploading files (for example, if a satellite has a bandwidth of 01bytes per mnute and 3fies, every file will get ge 3bytes per minute. You'll have 1unused byte of bandwidth). You can't transfer a partially uploaded file from a satellite. Devices aren't limited on the number of downloads/uploads they can do.
If a device goes out of range of a satellite during the transfer of a file (either way) the partialy downloaded file shoud be removed from the recipient. This does raise the question of whether or not you should start transferring a file if it's obvious that it wont finsh. Soving this probem is mostly algorithmic and isn't particularly interesting to the point of this assignment so you don't have to do anything specia here: f someone asks to transfer a file... begin to transfer it.
Satellites
There are 2specialised types of satellites (and one basic one). Satellites have a set amount of bandwidth for transferring files and a set amount of storage.
Default direction for all satellites is positive. StandardSatellite
Moves at a linear speed of 2,50 kilometres (2,50,0 metres) per minute per minute
Supports handhelds and laptops only (along with other satellites)
Maximum range of 1500kilomeres (150,00metres) metres)
Can store up to either 3 fles or 08 bytes (whichever is smallest for the curent situation).
Can receive 1byte per minute and can send 1 byte per mnute meaning it can only transfer 1fie at a time.
ShrinkingSatellite
Moves at a linear velocity of 10kilometres (1,0,0metres) per minute per minute
Supports all devices
Maximum range of 20,0kilomeres (20,00metres) metres)
Can receive 51 bytes per mnute and can send 01btes per minute.
Can store up to 051bytes and as many files as fits into that space.
Has a 'quantum compressor' meaning all files stored on the satellite that contain the phrase "quantum" only take up two-thrds (2/3) of of their original size.
Lowercase quantum is fine, you don't need to worry about any casing here, no need for case insensitivity, and the fie simpy just has to contain "quantum" anywhere
This sort of compression means that the 'data' only takes up 2/3of it's orginal size but when sending/receiving the file it til has to to receive and send the full payload
For example the message quantum is 7bytes but compressed i 5bytes. Thus when sending it, it needs to send 7bytes and when receiving it, it would need to receive 7bytes.
Hint: You aren't actually doing any compression here, you can just keep/store the strings as they currenty are and treat the compression as a representation of what their fully transferred 'size' is.
RelaySatellite
Moves at a linear velocity of 150kilometres (1,50,0metres) per minute per minute
Supports all devices
Max range of 30,0kilomeres (30,00metres) metres)
Cannot store any files and has no bandwidth limits
Devices/Satellites cannot transfer files directly to a relay but instead a relay can be automatically used by sateites/devices to send to their real target.
For example if a HandheldDevice (range 5 0 , 0 0 0 k m ) is 2 0 0 , 0 0 0 k m away from a S t a n d a r d S a t e l l i t e that it wishes to communicate with, it is able to communicate to the satellite through the use of the relay if the relay is within 5 0 , 0 0 0 k m of the device and the satellite is within 3 0 0 , 0 0 0 k m (the range of the relay) of the relay.
Files being transferred through a relay should not show up in the relay's list of files.
Only travels in the region between 1 4 0 ° and 1 9 0 °
When it reaches one side of the region its direction reverses and it travels in the opposite direction.
This 'correction' will only apply on the next minute. This means that it can briefly exceed this boundary. There is a unit test that details this behaviour quite well called test R e l a y S a t e l l i t e M o v e m e n t in Task2ExampleTests . java
You can either do the radian maths here yourself or use the functions in src/unsw/utils/Angle.java to do comparisons.
In the case that the satellite doesn't start in the region [ 1 4 0 ° , 1 9 0 ° ] , it should choose whatever direction gets it to the region [ 1 4 0 ° , 1 9 0 ° ] in the shortest amount of time. As a hint (and to prevent you having to do math) this 'threshold' angle is 3 4 5 ° . If a relay satellite starts on the threshold 3 4 5 ° it should take the positive direction.
Relay satellites don't allow you to ignore satellite requirements (other than visibility/range), for example you cant send a fie from a Desktop Device to a Standard Satellite due to the fact that a Standard Satellite doesn't support Desktops. This should hold EVEN if a Relay is used along the way. (Since this was a late clarification it will NOT be tested by any marking tests).
HINT: because there are no bandwidth imits and you dont have to show any tracking of files that go through he elay. Keep it simple! Don't over-engineer a solution for this one. You'll notice that the frontend when drawing connections that utilise relays don't go through the relay as shown below.
Fi To save you some googling v = r * ω (where v is linear velocity i.e. metres per minute, ω is angular velocity i.e. radians per minute, and r is the radius / height of the satellite).
Visualisation
Ue
To help you understand this problem we've made a frontend for the application you are writing, we also have a reference impementation for you to refer to. You'll also find that the starter code will have a simple webserver to run this frontend for you (already written) such that you can run the UI locally.
https://blackout21t3.azurewebsites.net/
This is NOT necessary for you to get marks, and it is more there just for those that enjoy seeing something slowly come together as they complete tasks. It's possible and still quite nice to just use the reference implementation + JUnit tests to design and build your soution without ever having to run and test the UI locally.
⚠ As with any software, bugs could exist in either the frontend or the reference implementation. Thus you should treat the specification as the final word and not the reference implementation. If you do notice any bugs or issues, please raise it on the forum so it can get fixed (or a workaround will be provided). Furthermore as the frontend expects that most of the code follows the specification you may run into weird bugs if you have wildly different behaviour.
Functionality is listed below;
You can click on a satellite or a device to view it's properties, as well as all the files it currently has, send files to other sateites, create fies f it's a device, or delete the entity
You can mouse over any satellite/device to see all the possible targets
You can click on anything near the radius of Jupiter to create a device and anywhere else in space to create a sateite
There are buttons on the top left to refresh the screen (for whatever reason) as well as run simulations for set periods of time
If your backend throws any exceptions an error will popup in the UI and an error log will be in the Java output window n VSCode (exception transferring file tasks which require the throwing of certain exceptions).
4. Program Structure
File
Path
Description
Should you need to modify this?
BlackoutController.java
src/unsw/blackout/BlackoutController.java
Contains one method for each command you need to
implement.
Yes.
App.java
src/App.java
Runs a server for blackout.
No.
MathsHelper.java
src/unsw/utils/MathsHelper.java
Contains all the math logic that you'll require.
No.
Angle.java
src/unsw/utils/Angle.java
Contains an abstraction for angles that lets you easily
convert between
radians/degrees without having to worry about what 'state' it is currently in.
No.
ZippedFileUtils.java
src/unsw/utils/ZippedFileUtils.java
Allows you to zip/unzip strings, useful only for Task 3b)
No.
EntityI nfoResponse.java and FileInfoResponse.java
src/unsw/response/models/EntityI nfoResponse.java and
src/unsw/response/models/FileInfoResponse.java
Contains the result for certain functions in BlackoutController.
No.
Scintilla.java and auxiliary files;EEnvironmen.jjav,, Platform Utils.java, and WebServer.java
src/sci nti lla
Contains a small custom built wrapper around Spark-Java for running a web server. When run it automatically opens a web browser.
No.
Taskl xamp plT Tests.java
src/test/Taskl xamp plT Tests.java
Contains a simple test to get you started with Task 1
Yes, feel free to add more tests here or just create a new testing file.
Task2Examp plT Tests.java
src/test/Task2Examp plT Tests.java
Contains a simple test to get you started with Task 2.
Yes, feel free to add more tests here or just create a new testing file.
5. Tasks
Task 1 - Modelling - 6 marks (S)
This task is mainly focused on design, if you start with an initial design via a UML Diagram, you'll find this will be quite straightforward Very little logic exists in this first task.
All methods below exist in the class src/unsw/blackout/BlackoutController.java
Task 1 a) Cr eate Device
Adds a device to the ring at the position specified, the position is measured as an angle relative to the x-axis, rotating anti-cockwise
public void ~~~~~i~~ ( String viceId , String type, Angle pstion ~;
Task 1 b) Remove Device
Removes a device (specified by id). You don't need to cancel all current downloads/uploads (relevant for Task 2).
public void ~~~~~~~i ( String viceId ~;
Task 1 c) Cr eate Satellite
Creates a satellite at a given height (measured from centre of Jupiter) at a given angle
public void ~~~~~i~~ ( String taedisIl , String type, double tegih , Angle pstion ~;
Task 1 d) Remove Satellite
Removes a satellite from orbit. You don't need to cancel all current downloads/uploads (relevant for Task 2).
public void ~~~~~~~i~~ ( String taedisIl ~;
Task 1 e) List all device ds
Lists all the device ids that currently exist.
public ~i~~ < ~~~~~i > ~~~~i~~~d~ ~;(
Task 1 f) List all sat ellite ids
Lists all the satellite ids that currently exist.
public ~i~~ < ~~~~~i > ~~~i~~~d~ ;~
Task 1 g)Add ile t o device
Adds a file to a device (not a satellite). Files are added instantly.
public void ~d~~~~~~i~~ ( String viceId , String filname , ~~~i~~ otcen ~;
Task 1 h) Get device/sat ellite information
Get detailed information about a single device or a satellite.
Fi NOTE: i d s are unique, so no 2devices and/or sat ellites can have the same id.
public ~~~~~i~~~~~~ g ( String di ~;
E n t i t y I n f o R e s p o n s e is a struct that is supplied that contains the following members (it also comes with a constructor and a getter)
public final c ~~~~~~i~~~~~ {
/
~~~~i~~ final String di ;
/
~~~~i~~ final Angle pstion ;
/
~~~~i~~ final double gtehi ;
/
vtaeipr final String type;
/
vtaeipr final Map<String, foelRipIsnF > files ;
}
Fi NOTE: final for classes means it can't have subclasses, final for functions means they can't have overrides, and final for
members means they can't be modified after the constructor. You don't have to use it in the assignment.
M a p < . . > is similar to Dictionaries in Python and acts as a mapping between a key and a value. You can find more information here
Task 1 Example
You can test your implementations for Task 1using the smple test provided in the fle s r c / t e s t / T a s k 1 E x a m p l e T e s t s . java . Later you need to add more tests to properly test your implementations.
The method testExample uses a JUnit test to test a few world states. Please read the method testExample.
@Test
public ublic void stExample )( {
/
~~~~ fro ~ ~~ Example
BackuCntoler lackoutController cntoler = wen BackuCntoler );(
1 ~ 3 ~~~~~ ~~~~ and
~ ~~ ~~ ~~~ ~ ~ ~ ~~~~~~
1 ~ ~~ ~~~ ~ ~~~~~ out
cntoler . tSaelicr ( Salite1" , nrdSalite" , 01 + RadsOfJupiter , Angle . fomDgres ( 403 );
cntoler . tvaDeicr ( DviceA" , HanhldDvice" , Angle . fomDgres ( 03 );
cntoler . tvaDeicr ( DviceB" , LatopDvice" , Angle . fomDgres ( 180 );
cntoler . tvaDeicr ( DviceC" , sktopDvice" , Angle . fomDgres ( 03 );
~ ~~~~~~~~~ ~~~ ~~ and
LstAEqualIoingOder ( Arays . taisL ( Salite1" ,) cntoler . SaliteIds );(
LstAEqualIoingOder ( Arays . taisL ( DviceA" , DviceB" , DviceC" ), cntoler . ltDviceIds );(
ertEquals ( wen yftoReiIpEsn ( Salite1" , Math . toRdians ( 403 ), 01 + RadsOfJupiter , sktopDvice" ), cntrol
ertEquals ( wen yftoReiIpEsn ( DviceA" , Math . toRdians ( 03 ), RadsOfJupiter , HanhldDvice" ), cntoler . ftgneI
ertEquals ( wen yftoReiIpEsn ( DviceB" , Math . toRdians ( 081 ,) RadsOfJupiter , LatopDvice" ,) cntoler . getInfo
ertEquals ( wen yftoReiIpEsn ( DviceC" , Math . toRdians ( 03 ,) RadsOfJupiter , sktopDvice" ), cntoler . ftgneI
}
Task 2 - Simulation - 9 marks
The second tasks involves the actual simulating of the movement of satellites and transferring files
Task 2 a) Run he Simulation
This should run the simulation for a single minute. This will include moving satellites around and later on transferring fies between satetes and devices.
public void mtuaesil );(
MNOTE: T o help with testing a simulate(int numberOfMinutes) has already been written which just calls simulate() numberOfMinutes ' times
Task 2 b) List all entities n ange
Lists every entity in range of the specified entity that can communicate. Devices can only communicate with certain satellites (as specified in the Satellites section). Satellites can communicate with every satellite and a certain subset of devices (once again as discussed in the Sateites section).
For an entity to be in range it also has to be visible to the other entities (i.e. if you drew a line between the two entities that ne cannot go through Jupiter). This includes devices/satellites reachable due to relay satellites.
public tisL < tgnSri > omtgebluisIRncaE ( String di );
Checkout src/unsw/blackout/utils/MathHelper there are some very useful functions there that do the vast majority of the work for you, you shouldn't need to figure out any complicated maths.
Fi This is useful for 2c
Task 2 c) File Transferring
Devices/Satellites can communicate by transferring files between each other. Files transfer progress can be measured by looking at g e t I n f o ( S t r i n g i d ) which contains a map of all files currently transferred/being transferred with the current progress being (double)data.length() / fileSize * 1 0 0 . You can only transfer files to entities in range.
public void dneFils ( tgSinr filName , tginSr fromId , tgnSri toId ) throws fxTtoacpeilnEsFr ;
This function should throw an exception in the following cases (the message is important and will be marked), al of these Exception casses should derive from the exception class FileTransferException and are provided for you.
File doesn't exist on f r o m I d or it's a partial file (hasn't finished transferring): should throw u n s w . blackout. V i r t u a l F i l e N o t F o u n d E x c e p t i o n with message equal to the file name
File already exists on t a r g e t I d or is currently downloading to the target: should throw
u n s w . b l a c k o u t . V i r t u a l F i l e A l r e a d y E x i s t s E x c e p t i o n with message equal to the file name
Satellite Bandwidth is full: should throw u n s w . blackout. V i r t u a l F i l e N o B a n d w i d t h E x c e p t i o n with message equal to whatever satellite has too little bandwidth
i.e. if you have a bandwidth of 8bytes per minute and are currently uploading/download 8 iles, you cannot upload/download any more files.
No room on the satellite: should throw u n s w . b l a c k o u t . V i r t u a l F i l e N o S t o r a g e S p a c e E x c e p t i o n with message equal to Max Files Reached if the lack of room was due to a max file cap (for example standard satellites can only store 3fles) or Max Storage Reached if the lack of room was due to a max storage cap (for example standard satellites can only store 80 bytes).
You'll find all the exception classes in once place s r c / u n s w / b l a c k o u t / F i l e T r a n s f e r E x c e p t i o n . j a v a , exceptions are a great case for a static nested class; for the sake of this assignment this s not a detail you need to worry/care about, just use hem as you normally would. For example throw new F i l e T r a n s f e r E x c e p t i o n . V i r t u a l F i l e N o B a n d w i d t h E x c e p t i o n (" S a t e l l i t e 1" ) .
Note: you don't have to throw anan exception for the case that the entity s out of ange/not visible since you can presume hat all entities will be n range for at least the first minute.
Fi We won't give you any very malicious test cases where this will make a difference but just for consistency; y ou should do the movement of satellites before you handle any download/upload for that simulation minute.
Task 2 Example
You can test your implementations for Task 2using the smple test provided in the fle src/test/Task2ExampleTests . java . Later, you will need to add more tests to properly test your implementation. For Task 2we supply a few different tests just to help you test a variety of cases.
@Test
public ublic void stExample )( {
/ ~~~~ fro ~ ~~ Example BackuCntoler lackoutController cntoler = wen BackuCntoler );(
1 ~ 2 ~~~~~ ~~~~ and ~ ~ ~ ~ ~ ~~~ ~~ ~ ~~~ ~~ and ~~~ 1 ~~~~~~~ ~~~ ~ pre and cntoler . tSaelicr ( Salite1" , nrdSalite" , 01 + RadsOfJupiter , Angle . fomDgres ( 403 );
cntoler . tvaDeicr ( DviceB" , LatopDvice" , Angle . fomDgres ( 103 );
cntoler . tvaDeicr ( DviceC" , sktopDvice" , Angle . fomDgres ( 023 );
tgSinr msg = Wrd!oHel" ;
cntoler . adFlToDvice ( DviceC" , FieAlpha" , Wrd!oHel" );
cntoler . desilnF ( FieAlpha" , DviceC" , Salite1" );
ertEquals ( wen foReiIplnsF ( FieAlpha" , " , msg . length ),( false ,) cntoler . getInfo ( Salite1" ). gtFiles (). get
cntoler . tmaelisu ( msg . tgnehl );(
ertEquals ( wen foReiIplnsF ( FieAlpha" , Wrd!Hoel" , msg . tegnhl ,)( true), cntoler . getInfo ( Salite1" ). get
cntoler . desilnF ( FieAlpha" , Salite1" , DviceB" );
ertEquals ( wen foReiIplnsF ( FieAlpha" , " , msg . length ),( false ,) cntoler . getInfo ( DviceB" ). gtFiles (). tge ( F"
cntoler . tmaelisu ( msg . tgnehl );(
ertEquals ( wen foReiIplnsF ( FieAlpha" , Wrd!Hoel" , msg . tegnhl ,)( true), cntoler . getInfo ( DviceB" ). getFil
/ ~ ~~ ~~ ~~~~~~ ~ ~ ~ ~ ~~~~ about ~~~~ ~ ~~ ~ ~ ~~~~~ out /
}
Task 3 (Extra Devices/Sat ellites) 5 marks 0
This task is intentionally meant to be difficult (intended for students aiming to achieve a High Distinction) and wil test the quaty of your desgn in Tasks 1and 2.2.
Task 3 a) ElephantSatellite - 3 marks
ElephantSatellites have the following properties;
Moves at a linear speed of 2,50 kilometres (2,50,0 metres) per minute p Supports Desktops and Laptops only (along with other satellites) Maximum range of 400kilomeres (40,00metres) metres)
Can store up to 90bytes
Can receive 20byte per mnute and can send 20byte per minute
When this satellite goes out of range of a device/satellite that is uploading a file, the ElephantSatellite doesnt deete the fie but rather marks the file as transient, in which case it will continue the download from where it left off if the same device/satellite enters range agan (and the device/satellite isn't currently transferring a file). Elephant satellites don't effect transfers from the elephant satellite (unless it's to another elephant satellite).
However, it's not going to hold it forever; f at any point memory becomes anan ssue i.e. there s not enough space or new transfers) t will delete transient files (that aren't currently transferring) to make room.
What files you delete are up to you and you'll be awarded subjective marks based on the design you choose here. This is only worth 3marks and is more intended for students who are interested in this sort of optimisation problem, a brute force solution that just deetes the argest transient files until there is space will obtain 15/3of the maks here. Remember that files take up space equal to their maximum size, not their currently
downloaded size (to prevent issues where you can't finish a transfer that you started).
A more complex solution could incorporate ideas such as;
Transient files take up only as much space as their data, since you can always delete them to make room.
If a file no longer becomes transient it should make sure it has enough space to download before it attempts to continue though You could attempt to delete transient files from devices/satellites that are further away since they'l take onger to reach.
File names are unique so you could attempt to download the file from a different device/satellite.
Fi You don't need to do all of above to get the marks for this section and your solution doesn't have to be perfect, make sure to incorporate your thought process in the rationale.md file.
Task 3 b) CloudStorageDevice - 2 marks
This device acts like a desktop but it auto zips files that are stored on it resulting in their file size being smaler than their actua sze
Zipped files remain zipped while on satellites but should automatically unzip once transferred to a device that isnt a CloudStorageDevice (i.e. a HandheldDevice, LaptopDevice, or DesktopDevice ). This means they need less storage space on satellites but will require the full storage space of the original file on any target device (that isn't a CloudStorageDevice ). The order that this happens is very important! Unzipping/Zipping should only happen after the file has been transferred not during. That is if you transfer a zipped file of size 80 bytes (with unzpped being 021
120
bytes) to a device it'll transfer 80bytes to the device and then once the 80bytes have been transferred it'll unzip that same minute and you' end end up with 201bytes.
The video details this well, so I recommend you watch that if you don't understand this
You can use the functions ZippedFileUtils.ZipFile() and Z i p p e d F i l e U t i l s . U n Z i p F i l e ( ) to zip/unzip a file to shrink/expand it.
These commands zip files to a base64encoded sting (just for ease of use). Zipping small amounts of text is almost never worth it, so you won't see a difference (it'll actually be slower) for small amounts of text. For example the text "Hello World!" zipped goes from 21to 32bytes but the tF text "Hello World!" * 1 0 0 goes from 021to 43bytes. bytes.
For this reason, if the zipped text is larger than the unzipped version it should send the unzipped version. A helpful hint is that unzipFile is nice in the way that if try to unzip a normal string i.e. u n z i p F i l e (" H e l l o W o r l d" ) then it'll just return the string rather than throwing an exception.
Fi The reason why smaller amounts of text don't compress well is due to the fact that compression has overhead and for small amounts of text this overhead is quite high.