The goal of this assignment is to practice writing short Kotlin programs that
- use loops
- use conditional statements
- use the processing library functions
- process command line arguments
Before starting, follow instruction in the classpath how-to guide. I am assuming throughout this lab writeup that you have downloaded and saved the core.jar file in an appropriate place, and have defined your CLASSPATH environment variable appropriately, as described in the classpath how-to guide.
The programs
$ pkt CheckerboardKt 4
$ pkt CheckerboardKt 5
The convention is that the lower left corner square is always black. Note that your program must work correctly for any positive integer n, not just for n equal to 4 or 5. Additionally, your program should check that the user provides exactly one command line argument (as a positive integer) before continuing; it should give error message and quit otherwise.
$ pkt BearKt
fun bear1(x: Float, y: Float, w: Float, h: Float)
so that when bear1(x, y, w, h) is called, a bear face of width w, height h will be drawn with its upper left corner at (x, y). For example, this example run
$ pkt BearsKt
results from the fact that the file Bears.kt contains the line
size(800, 400)
inside its settings() definition, and the lines
bear1(60F, 80F, 200F, 200F)
bear1(260F, 20F, 200F, 150F)
bear1(280F, 180F, 150F, 200F)
bear1(450F, 40F, 300F, 300F)
inside its draw() definition.
fun bear2(x: Float, y: Float, w: Float, h: Float)
by changing the Bear.kt code so that calling bear2(x, y, w, h) works exactly like bear1(x, y, w, h). However, bear2 should use the translate and scale functions, and retains most of the bear face drawing code from Bear.kt.
$ pkt RandomWalkerKt 5000
squared distance = 1250.0
Make sure the program checks the command line argument(s) and gives appropriate error message if not exactly one argument is given.
mean squared distance = 195.75 mean squared distance = 1600.13064
As n increases, we expect the random walk to end up farther and farther away from the origin. But how much farther? Use RandomWalkersKt to formulate a hypothesis as to how the mean squared distance grows as a function of n. Use trials = 100,000 to get a sufficiently accurate estimate.
Make sure the program checks the command line argument(s) and gives appropriate error message if not exactly two arguments are given.
Program style and format
Follow the guidelines in the Style Guidelines. Is your header complete? Did you comment appropriately? Is your code indented consistently? Did you use descriptive variable names? Did you follow the input and output specifications? Are there any redundant conditions?
Gradesheet
We will use this gradesheet when grading your lab.
Submission
You should create a “zip” archive file containing all Kotlin programs and your completed readme.txt file. Be sure to include the completed readme.txt file in your zip file. Read zip how-to if you do not know how to create a zip file. Ask your lab instructor for help if you need it.
Submit the zip file via Moodle.
Powered by pandoc and hakyll. Last modified on: Wed Apr 01 2020 18:48:28 GMT+0530 (India Standard Time)
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme