首页 > > 详细

讲解 COSC 2P13 – Assignment 1 – Is this all an excuse to print ‘handsome Squidward’?讲解 Java程序

COSC 2P13 – Assignment 1 – Is this all an excuse to print ‘handsome Squidward’?

Note: the most common problem for this style of assigned task is not reading.

Consider a small makerspace: several people needing to share a comparatively small number of stations and tools, while trying to maximize their output. Through the power of politely taking turns, they can create all sorts of wonderful things!

But the catch is that, eventhough some projects in the real world can be built as separate components and slapped together at the end, these projects need to be done rigidly in sequence, since everyone needs to know who’s actually going to be using what.

Stations:

And what might that “what” be, you ask? Well, we have several tools and stations:

•   FDM printer

o (What you’d normally associate with the term “3D printer”)

•   Resin printer

o Because sometimes you realize you haven’t had arash in ages!

•   Soldering iron

o Please don’t pick it up by the hot part …

•   Toaster oven

o Equally good for solder reflowing and tiny pizzas!

•   Lathe

o Because who needs their hair attached to their head?

•   Mill

o Of the general variety

•   Airbrush

o Great for when your lungs aren’t purple enough!

To confirm: any of the above maybe used infinitely, but only by up to one person/job at a time.

Naturally, all hobbies need to turn into a ‘side hustle’, so most ‘makers’ will end up trying to produce an inordinate number of a given piece. After all, why make one super-special chessboard just for you, when you can produce a thousand that are almost as good as a six-dollar one from Walmart, with terrible margins and nearly no profit?

And speaking of which, what are the projects/knickknacks they might be completing?

Projects:

Figurines for Mazes and Monsters

1.   First print the figures on the resin printer

2.   Then paint each using the airbrush

3.   Start amoral panic about DND and make a movie about it

•   Motor Controllers with Custom PCBs

1.   Use the soldering iron to tin the through-hole components

2.   Run the board through the mill to cut out the traces

3.   Brush on some flux

4.   Spread on the solder paste

5.   Throw it into the toaster oven to flow the solder

6.   Run it through the mill again to clear out any bridges

7.   Use the soldering iron to touchup any weak joints

8.   Plug in the motors

Chess Set

1.   Print out the white pieces using the resin printer

2.   Turn the white rooks on the lathe

3.   Print out the black pieces using the resin printer

4.   Turn the black rooks on the lathe

5.   Use the FDM printer to produce the board

6.   Box all the parts up together

•   Toaster pastry

1.   Pop a pastry into the toaster oven

2.   Consume half the pastry

3.   Regret not letting the pastry cool

4.   Resume consuming the pastry

5.   Wonder if it’s smart to use the same oven for both pastries and lead solder

•   Cup holder

1.   Throw the filament into the toaster oven to dry it

2.   Produce the basic holder on the FDM printer

3.   Use pure acetone in the airbrush station to smooth the layer lines

4.   Set it aside to dry for a bit

•   SAK scales

1.   Grab some aluminum stock

2.   Throw it onto the mill to carve out the scales

3.   Debur with a file if necessary

4.   Wash

5.   Throw into the toaster oven to dry completely

6.   Anodize

Flashlight

1.   Throw some round stock into the lathe to hollow it out

2.   Drill a couple holes

3.   Use the soldering iron to connect some batteries, an LED, and a switch

Since you’re managing the makerspace, you aren’t actually worried about the makers themselves (so no need to worry about e.g. names), but rather just the knickknacks that they might be producing, and how many.

Similarly you’ll notice the steps include a few things that don’t directly rely on the defined stations; those will never act as bottlenecks. Remember, this is first and foremost a concurrency task, and should be designed as such. (That means the primary concern is simply with ensuring none of the designated stations is used by more than one task simultaneously)

There are two parts to this assignment: a coding task, and diagram portion.

Coding

The minimal requirements of your program are:

•    Present the user with a menu, wherein s/he may decide:

◦ Which knickknacks to make (with up to seven knickknacks, this means up to 7 threads)

◦ The number of each knickknack to prepare (specifically a separate number for each knickknack)

◦ How often should progress be reported? (Explained further below)

•    Start a separate thread for each knickknack

◦ Each type should be implemented into its own thread, since it has its own lock requirements

◦ Each knickknack tries to report upon completing one (subject to above/below)

◦ Each knickknack type always reports when completed its iterations

▪ Obviously there's no reporting if none are being made at all

•    The program then reports on the total number of knickknacks produced

•    If this isn't obvious, both increasing the tally and output are also a'resource' (Of course, in this context, a ‘resource’ and a ‘station’ are interchangeable)

Additional notes:

Write your threads immensely clearly, and comment it.

•    Comment usefully. Don't add nonsense like identifying that a loop “loops”, or that  .lock() “locks”

•    Also,proper indentation, please?

Obviously, you'll have several  .java files for this.

Yes, you need to acquire locks for each resource, and it must be clear that you're following the ‘recipe ’. (For my own implementation, I actually included comments for when the 'extra steps'took place, just to keep track of where I was in the ‘recipe’, eventhough it didn't affect the output)

For the 'progress'part, you'll probably want to make at least a million of each knickknack, which ostensibly means calling a method to report 'another pastry baked', etc. millions of times.

That'd be silly.

So let the user also choose an X, for reporting 'every X knickknacks'.

•    e.g. 5,000,000 of each knickknack (35 million total), but only report onevery millionth knickknack

None of the steps absolutely need to hang onto stations indefinitely, but it might be reasonable for some to hold onto them abit longer than others. For the most part, this will only really affect the next section.

Use Java with IntelliJ. To be clear, use only Java and IntelliJ. (e.g. don’t try writing it in something else, dumping in additional nonsense or leaving something out, and then wondering why you received a zero for not having a complete project)

JDK 11 is preferred, but in particular the marker may or may not have above JDK 13.

You do not need to add any external libraries (including no extra .jar’s outside of possibly BasicIO per below). Please adhere to coding conventions covered in the course. Remember: these sorts of assignments are designed to reinforce very specific concepts; you’re not evaluated based on whether or not the outcome happens to align with what’s desired (nor do you get free marks just because you ‘submitted files’).

You are permitted to use that BasicIO library from first-year, if you wish.

You certainly aren't required to. e.g. Scanner for input and System.out.println are more than adequate. Don't bother with javafx/swing/awt, for the sake of simpler grading. Make sure to include sample output.

Again, please don’tbother with any random libraries. Beyond the basic threading/mutual exclusion and IO for Java, you shouldn’t require anything else. (Please remember you’ve been given sample on the Brightspace page)

Diagram

Being able to visualize things is important. Let’s try out Draw.IO!

There's a version you can install, but you can also just use the website:https://app.diagrams.net/

For some knickknacks (however many you need to do this), show:

•    Sequences in which you could request/release locks for the knickknacks, such that:

◦ A deadlock is possible

◦ Include a schedule of interleaving those steps that creates a deadlock

◦ A resource allocation graph proving the deadlock

•    Sequences in which you could request/release locks for the knickknacks, such that:

◦ Avoiding a deadlock is possible

◦ A schedule of interleaving those steps that does not create a deadlock

◦ A resource allocation graph proving the absence of deadlock

To confirm: whatever sequences you choose, they must be supported by the original ‘recipes ’!

•    This isn't as restrictive as it initially sounds

As a tip: if you actually do this part after the coding portion, you might need to force yourself to unlearn’ how the steps work. In particular, if you code it correctly there obviously won’t be any possibility of deadlocks, but only because you did it correctly. The first part above (for triggering the deadlock) is to emphasize why that ‘doing it correctly’ part actually matters.

Additional requirements:

•    Using draw.io is mandatory

•    These are sometimes a nuisance to grade, so include all files (the .drawio/xml file, and also a .pdf)

◦ You might find it safer to additionally include a .png copy

◦ No, you can't hand-draw it. No, you can't screenshot. Both lead to irritation and huge files

Submission

Include everything you used to make everything. Bundle everything into a .zip file.

•    Not a .rar. Not a .7z. Not a .tar.gz

•    Ignore this step, and you will receive a zero ◦ No, seriously

▪ You remember the part about this thing being worth 20% of your final grade, right?

•    I'm not kidding; this is entirely within your control

◦ If you think this is getting excessive, this disclaimer gets a bit bigger each term

▪ (For a reason)

Submit the .zip through Brightspace. Remember it can get a bit laggy at times, so please don't leave yourself 40 seconds to submit.

Or 2 minutes

▪ Or 4 minutes (again, these notices keep getting longer and longer…). Seriously, just submit it?



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

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