Author Archives: Mr. M

String Assignments SUPA 2015-16

Unit 3 Strings

substrings1

Alice Unit 2

This Page

      1) Quiz topics overview
      2) Unit 2 assignments

Unit 2 Quiz (mid -november-ish)

  • Review sheet with answers posted in Google Drive
  • converting other bases to decimals (unit 1)
  • methods vs functions
    • definitions
    • meaning of ‘return a value’
    • screenshots from Alice with connection to these definitions
  • variables
    • definition
    • types of variables
      • number
      • boolean
      • string
    • use of strings
  • identify where the ‘local variable’ button is in Alice


return-value-to-variable-alice-2

 


Drag Racing:

      1.  ( DO NOT SUBMIT THIS VIA Google classroom.   Show me this in class)
      2. Use at least 1  comment  Link
      3. Create a world with a road (from the City collection) and two cars (from the Vehicles collection).
      4. 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.
      5. Put an object at the end of the race to signify the ‘finish line’
      6. When the world is played, the cars should simultaneously move to the other end of the road and stop (You must use “do together”).
      7. use the “move” method for both carsmove-method
      8. Change the duration  of the move method (see pic below) so that one car arrives before the other).
        alice-duration-website
      9. Position the camera  so you can see the cars as they approach the end of the drag strip.
      10.  use a function  to figure out how far they should move (You want to replace the value “5 meters” with a distance function)

Then modify it

      1. create a variable called  driveDistance  and set its value to 1
        1. set the value of driveDistance   to the returned value of a the distance in front of  function
          unit-2-drag-race-variable-drivedisatnce-highlight
      2.  the car should move forward   driveDistance   meters

Space Ship Repair

spaceship_repair

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.

      1. 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.
      2. create a variable called walkingDistance (to represent how far the astronaut must walk)
      3. set the value of walkingDistance  to the returned value of  a proximity function.screenshot.44
      4. 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. Hint : to get the spaceship guy to move in the right way (towards the ship). Use the “turn to face” method turn-to-face
      5. The repaired ship should then fly away, off the screen.

Before submitting check out some examples of code that prior students used and that did not get full credit here .

 


Apollo 15

apollo-15-animated_gif_louis

      • 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”)
        1. 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.
        2. Create a variable called  dropDistance
        3. set the value of this variable to the returned value of a distance function to make the objects fall the distance above the ground. Use screenshot.1289
        4. Make the two objects fall down the value of the dropDistance

 

 

B Before handing it in, look at some examples of work that students did and that did not receive full credit,. here.


 

End of Unit Open assignment

      • Tell a short story that
      • at least 3 objects
      • at least 2  variables
      • at least 2 functions
        • sets the value of a variable to a returned value of a function
      • uses that variable to move one of the objects
        • ie make sure that your variable is actually used to do something.

Below is just one example. Your story can be about any topic.

end-of-unit2-alice


Old assignments (ignore)

Penguin on a Table: Create a world with a penguin and a table. The penguin should be facing the table, standing next to it. The penguin should simultaneously flap its wings (use the wing_flap method) and move up in the air a distance that is exactly 1 meter higher than the height of the table. You can call the table’s height function to get its height. The penguin should then move forward to approximately the center of the table, and then move down to the surface of the table

 

What as a String

Intro to CS 2015-16

Intro to CS 2015-16

Alice Unit 1

  • 1) Complete packets #3- 8  by Wednesday the 24th
  • 2) Assignment #1, Due Friday October 3rd
    • at least 10 instructions
    • modify a ‘subpart’
    • 1 do-together statement
    • at least 3 different objects
    • Worth 7 points.
    • To get a 7/7 you must achieve the ‘wow factor’–ie go above and beyond to create a superior final project
  • Quiz: TBA
    • binary number systems (see dropbox notes for review)
    • converting from various bases to base 10 (see dropbox notes for review)
    • comment vs instruction in Alice

Last  year’s class

Bank Runner Class

Bank Class

This is a modified version of this bank assignment

The responsibilities of this class are to

  • Methods
    • Person[] topAccountOwners(int number )
      • this method returns the  top number  owners with the greatest amount of cash in 1 account
    • ** boolean binarySearch( int accountNumber)  // this method should implement the binary search algorithm to determine if the account acct exists . Note for binary search to work, what must be true?
    • ** extra credit  Account[] sortByAccountId()
      •   this method returns an array of Accounts sorted by amount in the account

 

 

Bank Account Inheritance Assignment

Person Class

This page is an edited version of this (old) assignment

Constructor

  • public Person( String _name, int _age)

instance Variables

  • private String name
  • private int age

 Methods

  • public String  getName()
  • public boolean equals(Person  other) // assume that two objects with same age and name are equal

Account – Super Class

Static Variable(s)

  • static private  int nextAccountNum

Constructor

  • public Account( double_balance, Person _owner)

instance Variables

  • private int  accountNumber
  • protected  double  balance
  • protected  Person[] owners

 Methods

  • public int getAccountNumber()
  • public void deposit(double amount)
  • public double getCurrentBalance()
  • public  boolean withdraw(double amount); // returns  false if  amount > this.balance
  • public boolean equals(Account other)
  • public String toString()
  • public void addOwner(Person p)
  • public void removeOwner( Person p)
  • public Person[] getOwners()

CheckingAccount extends Account

  • instance Variables
    • private int checksWritten
  • Acessors and Mutators
    • void writeCheck( double amount) –> tries to call super.withDraw() as long as the balance is enough and records a new check number

SavingsAccount extends Account

  • instance variables
    • private double interestRate
    • double[]  dailyBalances

    static variables

    • public static final int MINIMUM_BALANCE=100; // this is the absolute minimum amount of money that must always be in the account
  • methods
    • public boolean withdraw(double amount) //@override the withdraw() method to ensure that currentBalance the never gets below MINIMUM_BALANCE
    • public void recordDailyBalance() // @ record current day’s balance by storing it in   dailyBalances

 

After you have completed this, work on the Bank runner class.

Compiled and Interpreted Languages

Comilers and Interpreters

Retrieved from http://en.wikibooks.org/wiki/Introduction_to_Programming_Languages/Interpreted_Programs

Retrieved from http://en.wikibooks.org/wiki/Introduction_to_Programming_Languages/Interpreted_Programs

java-compiler-interpreter

retrieved from http://www.greenteapress.com/thinkapjava/html/thinkjava003.html

 

compiler_interpreter

retrieved from http://www.pasteur.fr/formation/infobio/python/ch05s02.html