Homework part 1
Was ridiculous. This assignment deffinetly requires you, to think out side of the box!
The assignment is to ask the User to for a Number 1-10.
Then depending on what number they give you, you need to print out a Number pyramid.
So if the user gives you 4
you will print out
1
22
333
4444
And ect... This will go on and on!
The trick to this assignment is to use two for loops.
Start out by prompting the user for a number
Have what ever value they give you, be turned into a variable...
An example of this would be
var userInp = prompt("Please Give me a Number");
Next you need to parse their input into a Real Number value
So the overall is to create a new variable, that takes the users input and parses it into a number!
This can be done by using
parseInt();
var userNum = parseInt(what goes here?);
Next we create a for loop that will count until we reach the userNum
for (var ind= 1; ind <= userNum; ind++){
//In here we document write our ind
document.write(ind);
}
This will print out all the numbers before the user input
So how do we create the pyramid.
This is smartest think about it by using pseudo programming.
We use the same process as our first loop. But we in bed it in our loop. So we create a second for loop.
But we need to place it somewhere. How bout in the first loop.
notice what were conflicting...
for (var ind2= 1; ind2 < ind; ind2++){
document.write(ind);
}
ind vers ind2
This way they can corresponds with each other.
thats it.
Theres one more line to enter and thats
which writes an html break
Figure out where all these lines go, and you completed this weeks first homework assignment!
:D
-Franky
Thursday, July 31, 2008
Week 03 Lab3 -- WBP
This lab was tricky at first, then I just had to think about it.
First of all, you need to understand what exactly a "for loop does.
heres the syntax of a for loop
for(initialize the for loop; give it a problem; tell it what it needs to do to fix its problem){
}
initialize the for loop -
You need to turn it on basically. For beginning, its always awesome to create a variable there. Something that usually is a number, that equals 1 or 0.
var aNum=1;
next you need to set a condition this is best when telling this aNum, that its smaller than another number.
aNum <=5;
Next how do we fix this problem, well we just need to + to aNum until it reaches 5
aNum++
This is how it would look.
for(aNum = 1; aNum <= 5; aNum++){
alert("we have looped " + aNum + " time.");
}
All we created was a loop that will run 5 times. See???
For loops are awesome if you want something to repeat several times, hence "loop".
Try it out.
The assignment calls for a document write that outputs.
01234
Basically I just showed you the exact way to do that
for (var aNum = 0; aNum<6; aNum++){
document.write(aNum);
}
This is less than 6 because the number is indexed. 012345??!!
Next we need to document write
1
2
3
4
5
This is trickier but a no brainer. Since we are document writing to an HTML page, we are allowed to use HTML tags as strings. This is awesome, because you could basically build a web page by just using javascript. WTFUNK!!!
for (var aNum = 1; aNum<=5; aNum ++){
document.write(aNum + "?");
}
what html tag do you use to create a break?
Last part
2, 4, 6, 8, 10
Basically this is the exact same thing. except,
we don't want to ++, we probably just want to add 2.
and We don't want to start out with 0 or 1. We probably just want to start with 2.
for (var aNum = 2; aNum <=10: aNum += 2){
//that was easy
// next we Document write
document.write(aNum + "? ");
//what would go there???
// 2, 4, 6, 8, 10
Thats it. For loops are dope! makes things much easier. as for While loops, and DoWhile loops???
Pfft. I have no idea how those work!
:D
First of all, you need to understand what exactly a "for loop does.
heres the syntax of a for loop
for(initialize the for loop; give it a problem; tell it what it needs to do to fix its problem){
}
initialize the for loop -
You need to turn it on basically. For beginning, its always awesome to create a variable there. Something that usually is a number, that equals 1 or 0.
var aNum=1;
next you need to set a condition this is best when telling this aNum, that its smaller than another number.
aNum <=5;
Next how do we fix this problem, well we just need to + to aNum until it reaches 5
aNum++
This is how it would look.
for(aNum = 1; aNum <= 5; aNum++){
alert("we have looped " + aNum + " time.");
}
All we created was a loop that will run 5 times. See???
For loops are awesome if you want something to repeat several times, hence "loop".
Try it out.
The assignment calls for a document write that outputs.
01234
Basically I just showed you the exact way to do that
for (var aNum = 0; aNum<6; aNum++){
document.write(aNum);
}
This is less than 6 because the number is indexed. 012345??!!
Next we need to document write
1
2
3
4
5
This is trickier but a no brainer. Since we are document writing to an HTML page, we are allowed to use HTML tags as strings. This is awesome, because you could basically build a web page by just using javascript. WTFUNK!!!
for (var aNum = 1; aNum<=5; aNum ++){
document.write(aNum + "?");
}
what html tag do you use to create a break?
Last part
2, 4, 6, 8, 10
Basically this is the exact same thing. except,
we don't want to ++, we probably just want to add 2.
and We don't want to start out with 0 or 1. We probably just want to start with 2.
for (var aNum = 2; aNum <=10: aNum += 2){
//that was easy
// next we Document write
document.write(aNum + "? ");
//what would go there???
// 2, 4, 6, 8, 10
Thats it. For loops are dope! makes things much easier. as for While loops, and DoWhile loops???
Pfft. I have no idea how those work!
:D
Wednesday, July 30, 2008
Week 03 HW3 -- Authoring
Ahh, Classes.
Unfortunetly I do not have the hand out in front of me, and the instructor is smart enough to keep nothing online. But I finished the homework and will do my best to explain whats going on.
To start off we created an Actionscript project.
We created a Custom Class called
InventoryItem
The assigment was to take the "author" value and turn it into its own class, that will contain author information such as. First name, last name, and birth date.
To do this I created a new class called
AuthorInformation
This class contains 3 variables called
private var _nameFirst: String;
private var _nameLast: String;
private var _birthDate: String;
In my public function I give the AuthorInformation the correct String values
public function AuthorInformation(nameFirst:String, nameLast:String, birthDate:String){
_nameFirst = nameFirst;
_nameLast = nameLast;
_birthDate = birthDate;
}
Then I set up a function for each variable that will return my String
public function getAuthorNameFirst():String{
return _nameFirst;
}
public function getAuthorNameLast():String{
return _nameLast;
}
public function getAuthorBirthDate():String{
return _birthDate;
}
}
}
Next In my InventoryItem class, I change author from String to the correct data type.
Which happens to be my New Class!
public class InventoryItem{
private var _quantity:Number;
private var _productName:String;
private var _author:AuthorInformation;
And I make sure that all my _author variables, are of AuthorInformation data type!
Get that?
Great, thats done. Now to actually set values within my AS project.
So
First I create my inventoryItem variable
which is of What DataType???
var author3:AuthorInformation = new AuthorInformation("Allen","Ginsberg","12/25/75");
Now I enter all my Values
nameFirst
nameLast
birthDate
You getting this???
Next I create an inventoryItem Variable, which is of my InventoryItem class
var inventoryItem_3:InventoryItem = new InventoryItem(?,?,?);
Now my values
which are...
private var _quantity:Number;
private var _productName:String;
private var _author:AuthorInformation;
*\Notice that
quanity is a number
productName is a string
and author is...???
of my AuthorInformation Class
So what would my values be
quantity is 225
productName is howl
and my AuthorInformation???
Well I declared all that in a variable called???
var author3:AuthorInformation = new AuthorInformation("Allen","Ginsberg","12/25/75");
var inventoryItem_3:InventoryItem = new InventoryItem(225, "Howl", author3);
You getting this?
Awesome thats it. Its done?! WTFUNK!!!
Lets trace!
trace ("Title: " + inventoryItem_3.getProductName());
trace ("Quantity: " + inventoryItem_3.getQuantity());
trace ("Author First Name: " + inventoryItem_3.getAuthor().getAuthorNameFirst());
trace ("Author Last Name: " + inventoryItem_3.getAuthor().getAuthorNameLast());
trace ("Author Birth Date: " + inventoryItem_3.getAuthor().getAuthorBirthDate());
You will get
Title: Howl
Quantity: 225
Author First Name: Allen
Author Last Name: Ginsberg
Author Birth Date: 12/25/75
TADA!!!
-Franky A.
Unfortunetly I do not have the hand out in front of me, and the instructor is smart enough to keep nothing online. But I finished the homework and will do my best to explain whats going on.
To start off we created an Actionscript project.
We created a Custom Class called
InventoryItem
The assigment was to take the "author" value and turn it into its own class, that will contain author information such as. First name, last name, and birth date.
To do this I created a new class called
AuthorInformation
This class contains 3 variables called
private var _nameFirst: String;
private var _nameLast: String;
private var _birthDate: String;
In my public function I give the AuthorInformation the correct String values
public function AuthorInformation(nameFirst:String, nameLast:String, birthDate:String){
_nameFirst = nameFirst;
_nameLast = nameLast;
_birthDate = birthDate;
}
Then I set up a function for each variable that will return my String
public function getAuthorNameFirst():String{
return _nameFirst;
}
public function getAuthorNameLast():String{
return _nameLast;
}
public function getAuthorBirthDate():String{
return _birthDate;
}
}
}
Next In my InventoryItem class, I change author from String to the correct data type.
Which happens to be my New Class!
public class InventoryItem{
private var _quantity:Number;
private var _productName:String;
private var _author:AuthorInformation;
And I make sure that all my _author variables, are of AuthorInformation data type!
Get that?
Great, thats done. Now to actually set values within my AS project.
So
First I create my inventoryItem variable
which is of What DataType???
var author3:AuthorInformation = new AuthorInformation("Allen","Ginsberg","12/25/75");
Now I enter all my Values
nameFirst
nameLast
birthDate
You getting this???
Next I create an inventoryItem Variable, which is of my InventoryItem class
var inventoryItem_3:InventoryItem = new InventoryItem(?,?,?);
Now my values
which are...
private var _quantity:Number;
private var _productName:String;
private var _author:AuthorInformation;
*\Notice that
quanity is a number
productName is a string
and author is...???
of my AuthorInformation Class
So what would my values be
quantity is 225
productName is howl
and my AuthorInformation???
Well I declared all that in a variable called???
var author3:AuthorInformation = new AuthorInformation("Allen","Ginsberg","12/25/75");
var inventoryItem_3:InventoryItem = new InventoryItem(225, "Howl", author3);
You getting this?
Awesome thats it. Its done?! WTFUNK!!!
Lets trace!
trace ("Title: " + inventoryItem_3.getProductName());
trace ("Quantity: " + inventoryItem_3.getQuantity());
trace ("Author First Name: " + inventoryItem_3.getAuthor().getAuthorNameFirst());
trace ("Author Last Name: " + inventoryItem_3.getAuthor().getAuthorNameLast());
trace ("Author Birth Date: " + inventoryItem_3.getAuthor().getAuthorBirthDate());
You will get
Title: Howl
Quantity: 225
Author First Name: Allen
Author Last Name: Ginsberg
Author Birth Date: 12/25/75
TADA!!!
-Franky A.
1st Post
Alrighty Here it is.
Im going to be posting all my Notes and Homework Assignments on this blog.
Why?
Well, first of all, I figure people getting annoyed having to be in class with me. Cause all I do is talk about how I know this stuff already. Basically I want to move on, I hate listening to the teacher explain this stuff over and over, and well that's the joy of school. RIGHT?
What should I do then, I should get off my but and walk around and help people! But I'm lazy, so I figure Ill start a blog with my Assignments and knowledge, hopefully I will Inspire!!!
There will be two Sections in this blog
Javascript and ActionScript 3
The classes I am currently taking are
Intermediate Authoring
and
Intermediate WBP
I will post for each homework Week. My explanation and samples of my HW, hopefully this will help people
PLEASE DO NOT PLAGIARIZE MY WORK.
If you use my blogg, show some funky respect yo!
Don't be an ass!...
Thanks, and peace out!
-Franky
Im going to be posting all my Notes and Homework Assignments on this blog.
Why?
Well, first of all, I figure people getting annoyed having to be in class with me. Cause all I do is talk about how I know this stuff already. Basically I want to move on, I hate listening to the teacher explain this stuff over and over, and well that's the joy of school. RIGHT?
What should I do then, I should get off my but and walk around and help people! But I'm lazy, so I figure Ill start a blog with my Assignments and knowledge, hopefully I will Inspire!!!
There will be two Sections in this blog
Javascript and ActionScript 3
The classes I am currently taking are
Intermediate Authoring
and
Intermediate WBP
I will post for each homework Week. My explanation and samples of my HW, hopefully this will help people
PLEASE DO NOT PLAGIARIZE MY WORK.
If you use my blogg, show some funky respect yo!
Don't be an ass!...
Thanks, and peace out!
-Franky
Subscribe to:
Comments (Atom)
