Sunday, March 30, 2008
Thursday, March 27, 2008
LoveTester!
In class we did the following examples:
- Print out to the console from info entered in a text field.
- Ask a user for a number and give the user that number doubled.
- Ask a user for a number and multiply it by a second number entered by the user.
To accomplish the second and third task we needed to first save the data (accessed on the text field with the .getText() method) and then parse the data (think casting!) as an integer.
Here's the code we used in class:
public void doubleNumber() {
numToMultiply = jTextField1.getText();
numToMultiplyBy = jTextField2.getText();
//Getting the info from the text field
numberToMultiply = Integer.parseInt(numToMultiply);
numberToMultiplyBy = Integer.parseInt(numToMultiplyBy);
finalNumber = numberToMultiplyBy * numberToMultiply;
//Double the number
// numToDouble = Integer.toString(numberToDouble);
//Convert the doubled number to a String
newNum.setText(Integer.toString(finalNumber));
// Set the label "newNum" with the doubled number!
}
private String numToMultiply, numToMultiplyBy;
private int numberToMultiply, numberToMultiplyBy, finalNumber;
The in-class assignment was to create a LoveTester that asks the user for 3-5 pieces of information about himself and 3-5 pieces of information about his lover. The complicated LoveTester Algorithm (patent pending) is going to reveal the level of attraction, lust, and love for the two people!
Tuesday, March 25, 2008
After the test, we are going to start designing with NetBeans
Sunday, March 23, 2008
Blog assignment #5: How do you comment when you write programs?
First, read this. On your blog, answer the following question: how do you comment when you are programming? Do you add attributes and methods to a class and then add comments at the end? Do you write comments as you code? Lastly, what did you think of the article. Title this blog post- Blog assignment #5.
Blog assignment #4:
The following blogs are very useful to aspiring computer scientists:
- http://www.codinghorror.com/blog/
- http://googlepublicpolicy.blogspot.com/
- http://googleblog.blogspot.com/
- http://scottaaronson.com/blog/
- http://www.techmeme.com/
- http://www.javablogs.com/Welcome.action
You may want to add them to your Google Reader account.
Blog assignments #1-3:
If you haven't done the first three blog posts, here are the links:
Thursday, March 20, 2008
Wednesday, March 19, 2008
Tuesday, March 18, 2008
Lunch Cart Example
* Class LunchCart-
*
* Attributes:
* totalProfit
* numSandwiches
* numSodas
* totalTaxes
*
*
* Methods:
*
*
* Class Employees(String employee_num, String emp_name, int hours_wked)
* Class Employees(String employee_num, String emp_name)
* {
*
* }
* Attributes:
* hoursWorked
* employeeNumber
* salary
*
*
* Methods:
* getTotalHoursWorked()
* setTotalHoursWorked()
* getEmployeeNumber()
*
*/
public class LunchCart {
//Input, output using Scanner
//Process data using relevant conditionals and/or looping.
//What's most important for the LunchCart!!
}
Add the guessing game to Google Documents
Here's your guessing game Guessing.java assignment
// you give tips based on how close or far they are. If they are 20+ digits away you can lol
//or if they are within 10-20, say they are within a decent range, otherwise say they are getting
//closer!
Monday, March 17, 2008
Thursday, March 13, 2008
Post URL for Tic Tac Toe code!
In the links add the URL to the Tic Tac Toe source code that you found. Title it "Tic Tac Toe Source Code".
First In-"Class" Assignment
Assignment 1
Wednesday, March 12, 2008
Organizing the web's information...
Tuesday, March 11, 2008
Car.java
* Car.java
*
* Created on March 11, 2008, 8:20 PM
*
* To keep accurate account of our cars.
*/
/**
*
* @author dfreer
*/
public class Car {
boolean start = false;
String engine = "";
String brake = "";
private String name = "Herbie";
/** Creates a new instance of Car */
public Car(String eng, String br, String n) {
//constructor
engine = eng;
brake = br;
name = n;
}
public String getEngine()
{
return engine;
}
public void changeEngine(String ch)
{
engine = ch;
}
public boolean startEngine()
{
start = true;
return start;
}
public String getName(){
return name;
}
public static void main(String [] args)
{
Car herbie = new Car("3.8L", "moderate", "George");
System.out.println(herbie.getEngine());
herbie.changeEngine("V8");
System.out.println(herbie.getEngine()+ " is the engine of the new and improved " + herbie.getName());
}
}
Monday, March 10, 2008
Install at home
What is the SDK? Here's a good place to start.
Download eclipse, netbeans, and bluej.
Download JDK 6 Update 5
Find five sites with Sun Certified practice questions online
Third post:
Find five sites that have sample Sun Certified Java Programmer questions and write a review of each of the sites on your blog.
Tuesday, March 4, 2008
As concisely as possibly describe on your blog the purpose of the following site:
Java API.
Second post:
What is the purpose of the Java Virtual Machine?