Friday, March 30, 2012
Intuitive(?) User Interfaces and Windows 8
How is that an intuitive UI?
I Did It!
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Exercise_7_4
{
class Point
{
public int x;
public int y;
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
public void DisplayPoint()
{
Console.WriteLine("In DisplayPoint()");
Console.WriteLine("Point at ({0},{1})", x, y);
}
}
class Square
{
Point topLeft;
Point topRight;
Point bottomLeft;
Point bottomRight;
public Square(Point startingPoint, int sideLength)
{
this.topLeft = new Point(startingPoint.x, startingPoint.y);
this.topRight = new Point(startingPoint.x + sideLength, startingPoint.y);
this.bottomLeft = new Point(startingPoint.x, startingPoint.y - sideLength);
this.bottomRight = new Point(startingPoint.x + sideLength, startingPoint.y - sideLength);
}
public void DisplaySquare()
{
Console.WriteLine("In DisplaySquare()");
topLeft.DisplayPoint();
topRight.DisplayPoint();
bottomLeft.DisplayPoint();
bottomRight.DisplayPoint();
}
}
class Program
{
static void Main(string[] args)
{
Point myPoint = new Point(3, 4);
myPoint.DisplayPoint();
Square mySquare = new Square(myPoint, 5);
mySquare.DisplaySquare();
//to keep console window open to view output
Console.ReadLine();
}
}
}
Output: (really basic, I know...)
In DisplayPoint()
Point at (3,4)
In DisplaySquare()
In DisplayPoint()
Point at (3,4)
In DisplayPoint()
Point at (8,4)
In DisplayPoint()
Point at (3, -1)
In DisplayPoint()
Point at (8, -1)
There are a ton of things I want to refactor (including the order in which the points are "drawn"), but I'm just so happy I got it! :D
Oh, What's the Point?
No, it doesn't work yet, but I'm still at it. Now I have to finish it or my failure will be forever entombed in internet archives...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Exercise_7_4
{
class Point
{
public int x;
public int y;
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
public void DisplayPoint()
{
Console.WriteLine("Point at ({0},{1})", x, y);
}
}
class Square
{
Point topLeft;
Point topRight;
Point bottomLeft;
Point bottomRight;
public Square(Point startingPoint, int sideLength)
{
this.topLeft.x = startingPoint.x;
this.topLeft.y = startingPoint.y;
this.topRight.x = startingPoint.x + sideLength;
this.topRight.y = startingPoint.y;
this.bottomLeft.x = startingPoint.x;
this.bottomLeft.y = startingPoint.y - sideLength;
this.bottomRight.x = startingPoint.x + sideLength;
this.bottomRight.y = startingPoint.y - sideLength;
}
public void DisplaySquare()
{
Console.WriteLine("I don't know what to put in DisplaySquare yet.");
}
}
class Program
{
static void Main(string[] args)
{
Point myPoint = new Point(3, 4);
myPoint.DisplayPoint();
Square mySquare = new Square(myPoint, 5);
mySquare.DisplaySquare();
//to keep console window open to view output
Console.ReadLine();
}
}
}
Still trying... :)
Thursday, March 29, 2012
Keeping Myself On Task
Without further ado (because writing a clever post would be just one more thing to delay me), here is what I'm working on right now:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Exercise_7_2
{
class Math
{
public static void Add(int num1, int num2)
{
Console.WriteLine("{0} + {1} = {2}", num1, num2, num1 + num2);
}
public static void Subtract(int num1, int num2)
{
Console.WriteLine("{0} - {1} = {2}", num1, num2, num1 - num2);
}
public static void Multiply(int num1, int num2)
{
Console.WriteLine("{0} X {1} = {2}", num1, num2, num1 * num2);
}
public static void Divide(int num1, int num2)
{
Console.WriteLine("{0} / {1} = {2}", num1, num2, num1 / num2);
}
}
class Program
{
static void Main(string[] args)
{
Math.Add(1, 2);
Math.Subtract(3, 2);
Math.Multiply(3, 5);
Math.Divide(81, 9);
// to keep the little console window open :)
Console.Read();
}
}
}
edited to show slight change in code...
Friday, March 9, 2012
Tools For Creation, Tools For Consumption
Back in January, Jeff Blankenberg blogged about the importance of being creators in our society and not merely consumers of other's creations. http://www.jeffblankenburg.com/2012/01/03/be-a-creator-not-a-consumer/ His post was a big motivator for me to finally get serious about developing my programming skills and getting to a place where I can be paid to do what I love.
I was reminded of his post when I saw the latest commercial for Samsung's XL Phone/Tablet hybrid. After whining a bit about how inconveniently big it is for a *mobile* phone, I started wondering if it could successfully replace a, small netbook our laptop. In the commercial, the XL is depicted as a fabulous, fast and handy tool for finding and organizing football stats. It's shown as a terrific tool for consumption. From my (limited) experience, that's what phones and tablets are best at.
Yes, it is possible (with great effort) to create with a phone or tablet. (I am "swyping" this blog post on my phone, hence the funny formatting and odd typos.) However, these devices are clearly better equipped to serve as content delivery tools. Add to this Apple's announcement that last month they sold more tablets than HP and Dell sold computers *all year* in 2011, and the shift in technology seems all the more sinister. I don't want to live on the Axiom (WALL-e, 2008) with amazing content available at my fingertips, but no easy way to actually create something. You probably don't, either.
Perhaps I'm just a dinosaur, complaining about the lack of a good keyboard (and video rental stores). Graphic artists, enlighten me on the creative possibilities of the handheld computers that arts rapidly replacing laptops and desktops...
Thursday, March 1, 2012
The Joys and !Joys of Code Year
I love Codecademy.com's Code Year. I really do. I look forward to every Monday (at about 9:30 am PST) when that lovely email arrives in my inbox, announcing the release of that week's lesson.
That said, ARGH! I took a little break from the lessons when my previously accepted code kept getting "oops, try again" errors. (ARGH!) I picked it up again this morning on Wally, my ancient little iBook G4. It worked beautifully for about two hours. Then the nonsensical error messages started up again.
ARGH!
Back to C#, I guess. There's always the new MIT RELATE physics course...