Author Archives: Mr. M

Alice Unit 3-4 Assignments

FIRST:  make sure you know:  how to use What as a String and perform Math expressions  . You will not be able to do this assignment until you understand both of the above lessons.

Assign 1) Area of Triangle

Reference packets : #11, #12

Create a world that has a character (person/penguin/whatever) that will ask the user for the height of a triangle and the base of a triangle, and  calculate its area

  1. 3  different variables  : height , base  and  area  of the triangle
  2.  ask the user for  a number  for the height of the triangle and store it into  height (How to ask user for a number)
  3.  ask the user for  a number  for the base  of the triangle and store it into  base(ask user for a number)
  4.   use area formula and Alice Math expressions to compute the area.  (Note: if you don’t know how to use Math, refer to packet 11 or read this post  )
  5. Read this article if you have not already. ( You cannot do step 6 until you have read it)
  6. Have your character say the area of the triangle  (remember  area  is a number. You must use what as a string to say it.

alice-area-triangle-take2


 

roman-translator-1-20

Assign 2) Roman Numeral Translator

Objective : to let the user type in a number between 1 and 10 and then have a character “translate” that into Roman Numerals ( I, II, III, IV, V, VI, VII, VIII, IX, X)

  • Ask the user for a number and store the return value into a variable called  numberToTranslate
  • use a series of “if/else tests to translate the number and say the appropriate Roman translation for each number between 1 and 10
  • Use “==” (link )  to test if two values are the same.screenshot61
  • if the user enters a number greater than 10 then  OR less than 1 , have your character say, use either a or b “Only enter numbers between 1 and 10”

either-or-roman-trans_1

Final result :

either-or-roman-trans_2

We are going to use the roman Numeral Translator file again, so it’s important that you don’t lose the file and give it a good name that you can easily recognize in the future.

Extra credit: Translate 1-20 (Note : You still need to display an error if they enter a number that is too big, which in this case would be >21)


Assign 3) MPG

mpg_v1_opt


 Create a world in which the

  •  Create 3 variables :  miles, gallons ,MPG   
    •  2 of the variables  store the return value of a function
      • The user is asked for the number of gallons  of fuel his or her car can hold. Use the return value of the ask user for a number function as shown below.screenshot21
      • Do the same thing for the the number of miles  that he or she can drive on a full tank. Use ask a user function to set the value of the miles variable.
  • a third variable called MPG .   This one will store the result of some math and will hold the car’s miles-per-gallon (MPG). Calculate the MPG with the following formulampg (2)

 

  • At the end , your character should say the value of the mpg  . (You must use what as a string )

Lastly,

  • use an if/else  as follows
    • if mpg is less  than 30, say “wow, what a gas guzzler”
    • else say “This car gets pretty good gas mileage”

Assign 4) MPG  Temp Converter with if/else

temp-conver_opt1

 

  • Create a variable called degreesFahrenheit   .
  • Store the return value of the ask user for a number function in  degreesFahrenheit  
  • Create a variable called  degreesCentigrade
  • Use the following formula to convert the degreesFahrenheit   to Centigrade using the following formula below:

     
  • use a character from thePeople collection to say the centigrade temperature.
  • Don’t forget that you can’t say numbers, you must use what as a string
  • use an if/else so that you say “Wow it’s cold” If the final temperature is less than 5 and “Whew it’s hot” if the temperature is greater than 30  (Centigrade)

 


Assignment 5) Circle’s Area and Circumference: Create a world with your choice of person from the Peoplecollection. When you play the world, it should

  • Ask the user for the radius of a circle. (This value should be stored in a variable ).
  • Use a circle shape to represent the circle.
  • The person should then say the area and the circumference of the circle.( Links for the circumference formula , area of a circle)
  • (For an extra point do the same thing with a “Sphere“. Ask the user for the radius and calculate the surface area and the volume.)  This should be done in the same file as the circle.

 

 

Rock Paper Scissors


Assignment 5-extra credit ). Look up the formulas for the volume and surface area of a cylinder . Ask the user for the height of the cylinder and the radius, which should be stored in variables. Then calculate the surface area and volume of the cylinder . See if there is a cylinder shape in the gallery to use as a visual aid. And have an object say the volume and surface areas.

Nested Loops Projects

 

Nested Loop Starter Code


Method 1) printRectangle()

Change the code from the demonstration of nested loops so that you output the following pattern below. Call this method printSqure()

screenshot.1416


Method 2 and 3)

diagAndBrders()                                                    noDiag()

diagonal_only                      diagonal


Method 4)

printMultiplicationTable()

 

multiplication-table-console-view

String Lab Assignment [loops]

In this lab, you will work with a GUI to validate the input in each text field . Below is a screenshot of the running program.

validate-user-input

 

  1. download the code: Validate Form Loop Version Starter Code 
  2.  If you’re using bluej, you want to run “main” as shown herevalidate-form-bluej
  3. Find the code section shown below. This is the one and only 1 area that you should be editingscreen-shot-code
  4. Validate the user input as described below:
  1. Name
    1. length of 3 >=
    2. only letters (spaces is ok)
  2.  Email
    1. Must include an “@”
    2. Must include a “.”
    3. the “.” must come after the “@”
  3. Phone
    1. XXX-XXX-XXXX
      1. where each”X” must be an integer value
      2. each “-” must be in the correct location
  4. Date of Birth
    1. To convert a String to an integer use Integer.valueOf(String str)
    2. Max age is 110
    3. Minimum accepted age is 18
      1. If the user is less than 18, display the message. “Sorry you must at least 18 years of age for this service”
  5. Password
    1. Length must be at least 5
    2. cannot include the name anywhere inside the password
  6. Zip Code
    1. Each character must be an integer
    2. Length between 3 and 5 , inclusive

 

If the user has no errors, then please show the message “Thanks for submitting your information ” , as shown below

validate-form_thx_for_submitting_V2

 

A  file that does a few test cases (be careful not to overwrite your work)

Setting up VIM

VIM is a very powerful editor.

Follow the steps below to set it up. I am using windows and you might need to slightly modify certain steps like #2 for Mac (not sure)

Part I : Install Git desktop program

1) first install git : https://git-scm.com/downloads

Part II. Install GVim

For Windows:
Download and run the executable  installer
2) Uncheck “make plugin directory” at install. (We will create our own folder called “bundle” later that serves the same purpose)

For Mac: 
(consider macvim and/or using homebrew)

 

setting up vim

 


For steps 3 and 4, you can just download this folder: bundle (unzip it and put it into your main Vim folder, as shown in picture above), or you can follow steps 3 and 4
3) create a folder called “bundle” in the core vim folder.
4) in “bundle”, you must put the vundle.vim folder (see picture at bottom). You must put Vundle.vim inside bundle.
5) Create a folder called ‘tmp’  . We will configure our vimrc  to store temporary files there (Otherwise, they get saved in CWD and youre directories end up getting littered with lots of ugly temporary vim files)
6)  Feel free to use my customized _vimrc . That file should be in your root vim folder as you can see in the screenshot at the bottom. (BTW, you must remove the “.txt” extension.)
7)Run Gvim . (If you’re using my vimrc  , you’ll get an error first time, but that’s ok). The actual gVim application is in the folder called vim80 (or whatever version of gVim you’re running. If you installed vim 7.9, then you’d look in the vim79 folder or the like)
8)Let’s install some plugins using Vundle. To do, just type: the following :PluginInstall  (Yes, do type the the colon)

 

To type you must press either “i” or “a” which puts you into insert mode.

Lynda PHP Assignments[2016-17]

Both classes

Back to SUPA 3rd/4th quarters

 

Should watch “history of php” from https://www.lynda.com/MySQL-tutorials/PHP-MySQL-Essential-Training/119003-2.html

and then

“configuring php” from https://www.lynda.com/MySQL-tutorials/PHP-MySQL-Essential-Training/119003-2.html

Then go to the appropriate video course

NOTE: if you were in CS II last year, you *must* use Option 1, unless you get permission from me.

 

PHP Web Design  PHP Mysql

 Skip introduction, do everything else

Unit 1

Skip installation, go right to “first steps”

 

Supa Web Programming 2016-17

Quarter 3

NOTE: if you were in CS II last year, you *must* use Option 1, unless you get permission from me.

  1. PHP
    1. Option 1 : PHP for Web Designers link
    2. Option 2: PHP with Mysql Essential Training link

You should use Option 2 if you either a) feel confident in your programming background or have experience programming outside of the class 2) took the AP class last year.

SKIP Installation unit except for Configuring php

 

Full assignment breakdown here 

 

 

Below are some courses that you can explore as you consider ramping up your skills for the 4th quarter independent study.

Further study in PHP .

  1. PHP and MySql beyond the basics (link) . Pre-req for the MVC patterns. This shows you how to use OOP, something I’d recommend for the AP students. Most MySql connections now require OOP(object oriented programming)
  2. MVC pattern for php applications link  . Note Laravel is, by far, the most respected framework . At the end, I would recommend using Laravel. If not, try codeigniter
  3. PHP and Ajax Good for anyone interested in modern websites . Or for more interactive games
  4. Creating Secure Websites (link)

HTML5/Javascript Games

  1. Learn how to use the most popular game framework, phaser.io, with this video : https://www.lynda.com/Phaser-tutorials/HTML5-Game-Development-Phaser/163641-2.html
    1. Making Asteriods with Phaser (link) . Asteriods is a classic “first game”. You would need to make more than just a single game, but it would be a good start.

 

Quarter 4

This quarter will be comprised of an extended independent project that can be focused on anything web related. Note: If you are taking next year’s AP class, you must choose a rigorous programming project.

a) choosing a long term project that requires extended learning.  At least 1-3 Lynda.com classes (I will need to see that you completed 100% of at least 1 class)

b) you must write a proposal that details

  1. what the final product will be
  2. What new skills/learning you will undertake to achieve this new product
  3.  what Lynda course(s) you will study to learn the skills from #2

Methods , Variables, Functions Alice 2 Projects

 

#1  Apollo 15 :

screenshot.235

 

During the Apollo 15 mission to the moon, astronaut David Scott performed an experiment to prove that Galileo was right when he said that any two objects dropped at the same time would land on the ground at the same time in the absence of air. Scott, standing on the surface of the moon, dropped a hammer and a feather and indeed both objects hit the ground simultaneously.(Again, you must use “do together”)

Create an Alice world that recreates the experiment. You will find classes for the astronaut, lunar Lander, and the moon’s surface in the Web gallery’s Space collection. You can find a class for the Hammer in the Objects collection. Substitute any object of your choice for the feather.

Note : for following 3 steps, see Example 1 below

  1. Create a variable called  dropDistance
  2. set the value of this variable to the returned value of a distance function to make the objects fall the distance to the ground. (If stuck, read this )
  3. Make the two objects fall down the value of the distance

Example 1 (help with steps 2-4)

Steps 2-4 are similar to what is happening in the following picture :

screenshot.7

 


#2 Space Ship Repair :

spaceship-repair-demo-2

Create a space world with an astronaut and two spaceships(from the Web gallery’s Space collection). One of the spaceships is stranded with engine trouble, and the astronaut has arrived in the other spaceship to perform a repair.

  • The astronaut should initially be positioned just outside one of the spaceships, about to perform a space walk to the other ship. When the world is played, the astronaut should initially be positioned just outside one of the spaceships, about to perform a space walk to the other ship.
  • create a variable called walkingDistance ( to hold the distance that the astronaut must walk)
  • set the value of walkingDistance  to the returned value of a a proximity function  . (If stuck, read this ).  Here are some tips on using proximity functions in Alice 2.0.
    • NOTE: It turns out that, in this case, the best proximity function to use is distance to .
  • When the world is played, the astronaut should float to the stranded spaceship, appear to work for a few moments, and then float back to the rescue ship.
  • The repaired ship should then fly away, off the screen.

#3 Drag Racing:

spaceship-repair

 

  • Use  at least 1 set of comments
  • Create a world with a road (from the City collection) and two cars (from the Vehiclescollection).
  • Resize the road as necessary to match the size of the cars. The cars should be lined up side by side at one end of the road, which is a drag strip.
  • When the world is played, the cars should simultaneously move to the other end of the road and stop(You must use “do together”).
  • Change the duration of the method call that you use to move one of the cars so it is faster than the others.
  • Position the camera so you can see the cars as they approach the end of the drag strip.
  • Put an object at the end of the race to signify the ‘finish line’ and use a proximity function to move the cars to the end.

drag-racing-2


#4  Open Ended Project

  • Two or more objects
  • Must tell some kind of story
  • use at least 1 variable
  • use at least 1 function

bolivar_open_proj_penguin_ball cwong_open_proj_tag

Limitations of Inheritance

why Interfaces Are Useful

We are going to write a class that sorts some of the classes we have already written –namely : the Account and Student classes that we wrote in the past. Specifically, this class is going to sort Student and accounts by their grade point averages and their account balances , respectively..

Organizer Skeleton class (You only have to fill in 1 method)

Class : Organizer

The Constructor

  • The constructor is completely written for you already. It creates an array of Accounts and an array of Student. It also sends the arrays to both of the sort methods described below. You only need to write 1 method : public static void sort (Student[] arr) which is described below.

Accessor Methods

  • Sort Methods
    • public static void sort(Account [] arr)// Implemented this for you
    • public static void sort (Student[] arr) //basically…modify the sort method above so that it works for the Student class by comparing how old they are

What if we wanted to sort the PlayList class and add the method void sort(PlayList[] lists)?

Answer: We’d have to yet again add a whole new method that is very similar to the two sort methods we already wrote