Adobe Designer and Developer Lounge

a place where designers and developers can get to know one another

I'd like you all to post your Encapsulation homework here:

Upload your text files or .as files and we'll hopefully get a few comments going.

Choose from at least 3 of the following Scenarios and give me a description of the name of a Class, the properties of that Class, and its functions. Go ahead and use UML Class Diagrams if you wish, or just list everything out, or even make actual .as files if you’re ambitious. Don’t worry about filling in the actual code, though a short explanation of what each function does would be helpful to those reading the code. We only need one Class per scenario.

Dance Tutorial:
Finish up the Class we started in class: DanceTutorial. Each DanceTutorial will have a sound element, a text element, and an animation element. There will be DanceTutorials for any number of actual Dances.

Pac-man Baddies:
You remember those ghost-dudes that pac-man was running away from (Binky, Blinky, Winky, or whatever they were named)? Make a class that encapsulates those bad guys. You might consider things like whether they’re running towards or away from Pac-Man, if they’ve been eaten, their direction, position, etc.

Employees:
Your company needs a simple employee-management application to keep track of how much vacation/sick time each employee has left for the year. Each employee needs to be represented in data with things like name, emergency contact info, etc. There are 3 types of time off: sick leave, floating holidays, and vacation.

Pages:
You are creating a children’s e-book where a user can flip through any number of pages. Each page has text, a background image, and any number of interactive animations. Each page needs to contain positioning information about the text and animations, as well as which animation to start first.

Temperature gauge:
You’re making a widget on your web page that shows the temperature. The gauge is a different color depending on what the temperature is. All data is received in Celcius, but it can be converted to Celcius, Fahrenheit, or Kelvin.

Share

Reply to This

Replies to This Discussion

Here a stab at the Children's Book - I know it's full of mistakes - but i thought i'd throw it out there before the thanksgiving break

---------------------------------------------------------------------------
package com.accessvia.wolf {


public class Book {

//interface
public var pages:Array = ["page1", "page2", ... ];
public var i:Number = pages.length;
public var pageNum:Number = i;

//content
public var text:MovieClip = "text_mc" + i;
public var background:MovieClip = "bk_mc" + i;
public var ani:MovieClip = "ani_mc" + i;

//positioning
public var posX_txt:Number = 0;
public var posY_txt:Number = 0;

public var posX_bk:Number = 0;
public var posY_bk:Number = 0;

public var posX_ani:Number = 0;
public var posY_ani:Number = 0;

//constructor
public function Book () {
trace ("the new book title is " + bookName);
}

//methods - interface
public function fwd () {
get pageNum
//check to see if we're at the end of the book
if (pageNum < pages.length) {
//go to next page
pageNum = pageNum + i
set pageNum
}
}

public function back () {
get pageNum
//check to see if we're at the beginning of the book
if (pageNum != pages.[0]) {
//go to previous page
pageNum = pageNum - i;
loadContent (pageNum);
}

}

//methods - display content

public function loadContent (pageNum) {
this.addChild(text + pageNum);
this.addChild(background + pageNum);
this.addChild(ani + pageNum);
}




}



}

Reply to This

Michele

Looks good. I'm wondering if some sort of timer delay variable would also be helpful.

Do you have an opinion on whether it would be easier have this class access the layout to decide on a new direction, or if there's is a better way.

Although I didn't think of it, it would seem like deriving this class from a tweening class might make a lot of sense to make the movements very fast, smooth and efficient.

Reply to This

My thought was a central application class that had an interval engine. As the application class created each ghost it would register them with the engine and then movement would be updated by each pulse/event generated by that engine. No tweening, just incremental updates to individual x and y positions unique to each instance.

Reply to This

Here's a basic skeleton class for a pacman ghost.
Attachments:

Reply to This

Thanks for being the first to take the plunge, Kathy.

First thing: A Book class may be a bit much to bite off right now. We'll get more into handling application logic in the next class, but there will probably be a lot of fairly complicated stuff going on in a theoretical Book Class... though I'm glad you gave it a shot as you can see some of the challenges involved.

So I would stay stick to a Page class, it should definitely be easier to encapsulate; you don't have to worry about stuff like navigating between pages, etc. you can focus exclusively on what is involved in showing a page. There will probably be some code for showing the page, taking care of layout, etc. And there will probably be some code for getting rid of the page, making sure everything is off the screen, etc. Remember to think in terms of focusing only on what a Page would need to take care of and not worrying about anything else.

Reply to This

Cool! Thanks for the feedback...I'll take another stab at it.

Reply to This

Here's my version for all of them... + = public. $ = Static

I'm really looking forward to any feedback, and to seeing how other people broke the problem down.
------------------------------------------------------------------------
> Dance Tutorials:

=====================
Dance extends QueSheet
---------------------
+CurrentlyLoaded
+ListOfDances
---------------------
+LoadMedia
+Pause
+Play
+Seek
+Stop
=====================


=====================
QueSheet extends Media
---------------------
+List (All Coordinated Media Sources)
+Position
+Speed
+State (Play, Paused, Stopped, Unloaded)
---------------------
+LoadMedia
+Pause
+Play
+Seek
+Stop
=====================


=====================
Media
---------------------
+bAutoLoop
+FnCallbackStarted
+FnCallbackEnded
+StartDelay
+Position
+State (Play, Paused, Stopped, Unloaded)
---------------------
+LoadCallback
+LoadMedia
+Pause
+Play
+Seek
+Stop
=====================


> Pac-man Baddies:

=====================
BadGuys
---------------------
+CurDir
+CurPosition
+TimeStart
+State (Chaseor, Chased, Dead, Flyback, Waiting)
+Speed
---------------------
+Delete
+Edit
+IsTouching
+New
+Move
=====================



> Employees:


=====================
Person
---------------------
+FirstName
+MI
+LastName

+EmerContactName
+EmerContactNum
---------------------
=====================
+New
+Delete
+Edit

=====================
Employee
---------------------
PersonID
+AccruedSickTime
+AccruedVacationTime
+ListSickDaysThisYear
+ListVacDaysThisYear
+VacTimePerYear
---------------------
+New
+Delete
+Edit

+SickTimeLeft
+SickTimeUsed
+VacationTimeLeft
+VacationTimeUsed
=====================

=====================
Company
---------------------
+ListHolidays
+SickTimePerYear
---------------------
+New
+Delete
+Edit

=====================


> Pages:

=====================
Book
---------------------
+CurPage
+ListPages
---------------------
+GetPage
+LoadPages
+PageFirst
+PageGoto
+PageLast
+PageNext
+PagePrev
+SavePages
+SetPages
=====================

=====================
Page
---------------------
+ListElements
---------------------
+GetPage
=====================

=====================
Element
---------------------
+Content
+Location
+Opacity
+ZOrder
---------------------
+ElementLoad
+ElementSave
=====================

> Temperature gauge:

=====================
TempGauge
---------------------
ListColorSetpoints
---------------------
+GetCelcius
+GetColor
+GetColorSetpoints
+GetFahrenheit
+GetKelvin
+GetTempGaugeGraphic
+SetTemp
+SetTempColorSetpoints
$TempCelciusToKelvin
$TempCelciusToFahrenheit
$TempFahrenheitToCelcius
$TempFahrenheitToKelvin
$TempKelvinToFahrenheit
$TempKelvinToCelcius
=====================

Reply to This

Here's my last-minute entry:

Temperature Gauge

Display Objects:
Temperature Display Window
Celsius Button - Up, Down, and Fade States
Fahrenheit Button - Up, Down, and Fade States
Kelvin Button - Up, Down, and Fade States
CurrentDisplayMode - Celsius, Fahrenheit, Kelvin states

Action:
Get temperature (www.temperature-whatever.com)
display in temperature window
Time increment update?

Functions:
if currentDisplayMode = Fahrenheit string (tempFahrenheit) + "F"
else currentDisplayMode = Celsius display ((tempCelsius * 9/5) + 32)) + string "F"
else currentDisplayMode = Kelvin display ((tempKelvin + 459.67) * 5/9) + string "F"

Change to Celsius
onPress Celsius button:
for Fahrenheit display ((tempFahrenheit - 32) * 5/9) + string "C"
for Kelvin display (tempKelvin - 273.15) + string "C"

Change to Kelvin
onPress Kelvin button:
for Fahrenheit display ((tempFahrenheit+459.67) / 1.8) + string "K"
for Celsius display (tempCelsius + 273.15) + string "K"

Change to Fahrenheit
onPress Fahrenheit button:
else Celsius display ((tempCelsius * 9/5) + 32) + string "F"
else Kelvin display ((tempKelvin * 9/5) - 459.67) + string "F"

Reply to This

Urgently looking for exercise files for Flash CS4 Professional Digital Classroom book. Just need the exercise files from the DVD (videos not required) as I lost the DVD which came with the book. Please send them to me via www.yousendit.com or upload them.

Would really appreciate.

Thank you.
Sahil Sehgal
ship2friends@gmail.com

Reply to This

RSS

About

© 2009   Created by Brad Tollefson on Ning.   Create a Ning Network!

Badges  |  Report an Issue  |  Privacy  |  Terms of Service