Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


COSC 1P02 Assignment 3

“It's like déja vu, but more comprehensive”


Refer to Sakai for due date

This assignment directly builds on your previous one. Ostensibly the basic goal is the same; this time you're making a night sky. You'll again be using procedural abstraction, but this time you'll be modifying your methods to use parameters, and will include at least one function. Also, the stars will be of randomly-selected sizes this time around.

You'll also be including one small additional feature to the complete illustration: a black background.

See below for a sample:

Because this is predominantly based on A2, you can refer there for the basic math and explanation. Instead, this specification will focus on what's unique:

● As hinted above, you'll need a method to create a black background

● Each drawn star needs a location, a value to scale its size, and a colour

● If the star 'knows' its size, it needs to communicate that to the method drawing a ray

● You need some function to calculate something

So long as your design for A2 was sound, this should require only minimal additional modification. If, however, your A2 solution was a bit rough, consider this an opportunity to reinforce your skills and improve upon your past work!

Tips:

● In case random colours haven't been covered in lab, you only need two things:

import java.awt.Color; (to get the library)

pen.setPenColor(new Color((int)(Math.random()*16777216)));

You're welcome to have the colour be a parameter, if you prefer

● To easily make a black background, you can set the pen colour to a very large width, and draw a few black lines

● The actual method for drawing the sky itself doesn't need any parameters (as it always 'fills the sky with stars')

With each drawn star requiring unique values, consider where you'd determine those?

● It's acceptable to still have the method for drawing a star decide for itself how many points (rays) it needs

A strong suggestion for what to choose as the function would be the calculation of the length of the hypotenuse (the length of the initial/final lines of a single ray).


Submission:

For submission, you must submit a .zip file containing the following:

A folder called Assign_3, containing your submission

Your NightSky.java source file

Your .drjava file, that you used to create the assignment

A .pdf copy of your starlight pattern

When the program finishes, before clicking Close, just click File → Print Image of Window... → and then select to print to a file

If you're having any trouble doing this on Windows, CutePDF might make it easier

If you find yourself struggling with the output shortly before you need to submit, for only this assignment, you can just use File → Save Window as Image... and save it as a picture instead

On Sakai, submit your .zip file as an attachment, and click to Submit.

Note: Do not submit a .rar, .tar.gz, .7z, etc. Every major operating system supports .zip, so it is mandatory if you wish to receive a grade for your assignment.


Standards:

Ostensibly, you'll be graded for following basic coding standards and documentation requirements. At the very minimum:

A comment at the top of all source (.java) files including your name and student number

Variable names that are either standard or descriptive

Using things like i and j for loop counters? Standard

Using a variable like count? We can guess what you meant

For any blocks of code (e.g. loops) insert a brief comment so the reader knows what's inside (e.g. what's being repeated)

● Put a comment in front of any method, to briefly explain what it does

Anything you think the marker might not understand? Add a quick comment

This probably isn't a concern for this assignment

Additionally, try to remember to fix the indentation of your source files. Jagged margins can be harder to follow along with.


DrJava (and other platforms)

If you aren't planning on using DrJava, you should consult with the course coordinator (Maysara) to ensure that's okay.

Make sure to include everything (i.e. the whole folder), to avoid forgetting an important file. (e.g. even if you include a .class file, and a .pdf copy of the source file, the marker can't confirm that compiles)