Category Archives: Computer Science

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

ALice Loop Assignments

ezgif.com-optimize

1)  Centigrade to Fahrenheit Modification: Modify the Fahrenheit to centigrade project as follows.

  1. Let the user do as many centigrade modifications as you want (like this link here)
  2. Then use a loop to do that many conversions

2) Miles Per Gallon Modification: Modify the miles per gallon projec. In this one, ask the user how many times they want the MPG program to run and use a loop like this. .Due wed/Thurs the 17th/18th

  1. Ask the user how many times, they want to do the MPG and use a loop like this
  2. Then use a loop to do that many conversions

3) Sea Plane Loop-the-Loop : Create a world with a sea plane (from the Vehiclescollection).Create an infinite loop that causes the sea plane to do a circular loop the loop. Adjust the style and duration editing tags to make the animation fast, and as smooth as possible.


EOU)  Open assignment. Your open project must have each of the following criteraDue before Winter vacation

  1. a variable
  2. store the return value of a function into that variable
  3. a loop of some kind

Objects In Java Unit

 

Unit 4  Objects && ArrayList

Unit 5 : Objects Continued

Unit 4** Alice Assignments

Assignment ): Tutorial 4-2 Gum Drop Fish Assignment will be graded (2 points) from packet #13 will be graded.  Download the GumdropBigFish world 

  • gum drop alice

Assignment 1 )   Miles Per Gallon: 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 use 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 , as shown below.

How to use “what as a string”

what as string 2

 

mpg_brandon

 


Assignment  3) Fahrenheit to Centigrade :

First, watch the animated gifs on this web page that explain how to use math in Alice

 

  • Create a variable called degreesFahrenheit  .
  • Store the return value of the ask_user to enter a number function
    • You should ask them for the degrees in Fahrenheit
  • Create a variable called  degreesCentigrade
  • Use the following formula to convert the degreesFahrenheit   to Centigrade using the following formula
  • 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

 

temp_convert_eric

 

 


 

Assignment 4) Modification of MPG

reopen the miles per gallon project

  • if the MPG variable <  20
    • say “What a Gas Guzzler”
  • else
    • say ” Your car is not a gas guzzler”

MPG Modification 1


Assignment 5) Modification of Fahrenheit to Centigrade

reopen the Fahrenheit to Centigrade project and add

  • if the degreesCentigrade  variable <30
    • say “It’s Very cold
  • else
    • say ” It is warm outside”

Assignment 6) 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 ).
  • 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.

Assignment 8 

ezgif-com-optimize

Roman Numeral translator

Here’s a gif showing partial code and what the finished project should look like
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
  • 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”screenshot59

 

 

  • use a series of “if/else tests to translate the number and say the write translation for each number between 1 and 10
  • screenshot61

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.


Assignment 7-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.


Assignment 8 ) Open Assignment

Create an Alice world that

  • uses a variable
  • uses a ask_user world function
  • uses a comment
  • uses an if/else
  • uses a math expression with more than one operation (ie addition and also multiplication or multiplication and also subtraction)
  • tells a story

 

Unit 4 . Objects & Arraylists

Unit 4  Objects && ArrayList

 

Part I

import java.util.ArrayList

 

RPN Calc Assignment

Use A Stack Class to create a RPN calculator

Part I : RPN Math Class

Input: String representing RPN syntax

Parse the String  (Maybe a separate method)

Calculate the return value of the RPN syntax.

Examples of Syntax

  • “3 -5 * “ -15

 

IF invalid syntax is entered, your method should throw an ArrithmeticException

Things to Support

  • negative numbers (vs subtraction)
  • decimal points
  • multiple spaces between characters

Part II: The GUI

  • Numbers 0-9
  • negative
  • 5 operators
  • Enter button
  • Clear button
  • System.exit(0) button
  • ** EC: support for keypresses including enter

Part III: **EC : Infix to postfix (allow users to enter numbers in infix)

 

Send me the jar file.

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