View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Jamin's Milestone1




Squeak Milestone 1


by Jamin Hogan


gte159h
TA: Ashley Taylor







Hello, and welcome to my Milestone 1 extra credit page. With this page I hope to clarify the usage and functionality of my Milestone 1 for CS2340. The assignment of Milestone 1 was to produce a mathematical equation in an eye pleasing and correct form.
see:
for further details.
This image (Form) is determined by the input of the user who it is assumed understands the basics of Squeak function calls.


The basic squeak function call is called on an object and references something within tht object. In the case of

MathEquation from: 'hello world'.

the object MathEquation (which in this case is a class) is having its from: method called. The string 'hello world' is being passed as a parameter. Since the goal of MathEquation as per the instructions, was to return a Form, nothing is displayed. That is, until you add the 'display' method.

(MathEquation from: 'hello world')display

not if you look closely you will notice that there are parenthesis around MathEquation from: 'hello world'. This causes that entire "block" of code to be considered a single object by Squeak. It is that object (MathEquation from: 'hello world') that has its display method called, thereby generating an image to the Squeak environment.

For an example of a working display in Squeak, click on the thumb.







Math Objects





In Milestone 1 i had to create a simple program that would handle rather complex equations and
display them onto the Squeak environment.
Here is an example of a working test case:



My design utilized a MathObject class that held 2 variables
in an instance accessor and 2 modifiers. Since the only Math function that requires less than two
operators (in the assignment given) is MathEquation, all other function classes extended this single
MathObject class.





Since the instance variables in these classes are a simple call away, the functional classes
MathSuperscript, MathSubscript, GreekSymbol and MathFraction contain virtually no code. An example of the
single class method that these contain is:

from: t1 with: t2
| t3 |
t3 _ MathSuperscript new.
t3 setArgs: t1 and: t2.
^ t3

The only exception is MathOperation, simply because it contains an additional operator variable. This
variable is handled within the MathOperation class in its instance section. This was done because it seemed
pointless to put information into MathObject that would only be used by the exception(MathOperation). As can
be determined by the code segment above, each of these classes returns an instance of itself upon completion
of self-generation(ooo.. that phrase sounds cool).


These instances are caught as the parameters within other instances and further returned. In this way the
MathEquation class will eventually receive a single object(assuming more than a string input is entered) that
contains the entire structure of the equation.





Math Equation






In MathEquation we receive either a String, Form, or complex object:

  • If we receive a String, well, it is
    pretty easy. We just turn it into a Form and slap it up on the screen.

  • If we receive a Form, it is even easier, we just send it to traceEquation, which turns it into a Form and
    slaps it onto the screen.

  • Lastly, we may receive a complex object. That means that we are receiving an instance of one of our Math Object
    classes (MathFraction, MathOperation, MathSuperscript, MathSubscript, GreekSymbol). We send that object to
    traceEquation which begins to parse it.





Now I really shouldn't pat my back here too much. The parsing is simple, and my back has nothing to do with my
code. traceEquation determines the parameters in the current object. If both parameters are Strings and/or Forms,
then the MathObject can be directly turned into Form(a call to makeForms). Otherwise some sort of recursion is necessary. The parameters
of the MathObject are set to new values after they have been analyzed as MathObjects as well.



The result of this is the creation of a single Form: an uber-form.

note: my program had to be reclaimed from the changes file (due to an accident) please forgive the variable names.







Examples






Here is the ST file for
download:
Here are some example inputs:




(MathEquation from: (MathOperation operator: '+' with: '12' and: '123')) display

(MathEquation from: (MathSuperscript from: '23' with: '222')) display

(MathEquation from: (MathSubscript from: '1' with: (MathSubscript from: '12' with: (MathSubscript from: '123' with: (MathSubscript from: '1234' with: '12345'))))) display

(MathEquation from: 'hello there')display

(MathEquation from: (MathFraction from: '11' over: '123')) display

(MathEquation from: (GreekSymbol named: '#Gamma' sized: '20')) display

(MathEquation from: (MathSuperscript from: 'y' with: (MathFraction from: 'sin(x)' over: 'x'))) display

(MathEquation from: (MathFraction from: (MathSuperscript from: 't' with: 's') over: '235')) display

(MathEquation from: (MathOperation operator: '-' with: (MathSuperscript from: '(x+9)' with: '2') and: '99')) display

Note: the following is not for the feignt at heart..

(MathEquation from: (MathOperation operator: '-' with: (MathSuperscript from: (GreekSymbol named: '#xi' sized: '20')
with: (MathFraction from: (MathSuperscript from: (MathSuperscript from: 'y' with: (MathFraction from: 'cos(z)'
over: 'x')) with: '72') over: '123')) and: (MathFraction from: (MathSubscript from: (MathFraction from:
(MathSuperscript from: (MathOperation operator: '-' with: (MathSuperscript from: (GreekSymbol named: '#lambda'
sized: '20') with: (MathFraction from: (MathSuperscript from: (MathSuperscript from: 'y' with: (MathFraction
from: 'tan(y)' over: 'x')) with: '21') over: '123')) and: (MathFraction from: (MathSubscript from: (MathFraction
from: (MathSuperscript from: 't' with: 's') over: (GreekSymbol named: '#alpha' sized: '20')) with: (MathOperation
operator: '-' with: (MathSuperscript from: (GreekSymbol named: '#Gamma' sized: '20') with: (MathFraction from:
(MathSuperscript from: (MathSuperscript from: 'y' with: (MathFraction from: 'sin(x)' over: 'x')) with: '42')
over: '123')) and: (MathFraction from: (MathSubscript from: (MathFraction from: (MathSuperscript from: 't'
with: 's') over: (GreekSymbol named: '#alpha' sized: '20')) with: '15') over: 'x'))) over: 'x')) with: 's')
over: (GreekSymbol named: '#alpha' sized: '20')) with: (MathOperation operator: '-' with: (MathSuperscript
from: (GreekSymbol named: '#Delta' sized: '20') with: (MathFraction from: (MathSuperscript from: (MathSuperscript
from: 'y' with: (MathFraction from: 'sin(x)' over: 'x')) with: '92') over: '123')) and: (MathFraction from:
(MathSubscript from: (MathFraction from: (MathSuperscript from: 't' with: 's') over: (GreekSymbol named:
'#alpha' sized: '20')) with: '1') over: 'x'))) over: 'x'))) display



Link to this Page

  • Cases last edited on 30 July 2011 at 2:33 am by r59h132.res.gatech.edu