Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Array questions
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Nathan4102




PostPosted: Fri May 17, 2013 4:09 pm   Post subject: RE:Array questions

Oh, now I see how classes can be really useful. I'll probably dive into this stuff when I learn Java sometime soon hopefully. Thanks for the advice and examples!
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Fri May 17, 2013 4:12 pm   Post subject: RE:Array questions

IF you ever get to that stage, you should look this up: http://processing.org/

It's simple like turing and it's structured very similarly, but it has the power and syntax of Java.

Learn turing first though
Nathan4102




PostPosted: Fri May 17, 2013 4:16 pm   Post subject: RE:Array questions

Well I'm going to need to learn Java too, since my co-op in 8 months will be using Java, plus my computers course in the fall will be in Java, so I'd like to get a bit of a head start before that class starts. The questions isn't IF I get to that stage, it's WHEN. Wink
Raknarg




PostPosted: Fri May 17, 2013 4:17 pm   Post subject: RE:Array questions

Well in that case, you're probably better off actually learning Java rather than something close to java Razz

also yay 1000 posts
Nathan4102




PostPosted: Fri May 17, 2013 4:44 pm   Post subject: RE:Array questions

That's what I was thinking, and gratz! I'll catch up to ya soon!
Panphobia




PostPosted: Fri May 17, 2013 8:45 pm   Post subject: Re: Array questions

This here was one of my major OOP assignments in grade 12 compsci, it isn't that hard but its just to give a feel on what it looks like
code:
ICS4U ? Object Orientation Assignment Part 2 ? Novel Knights and Wicked Wizards

The world contains two types of humans: knights and wizards. Humans can be represented in the world as small squares. Knights are blue and Wizards are red. The relationship between Humans, Knights and Wizards can be described by the following hierarchy:



All humans can perform certain actions as described by the following interface:
https://lh3.googleusercontent.com/3tZdinTjzSV7s4YBNvBN7KmSlDf-cyXYDeC3Xm1ohLrNwEycpjUmBTWDT61j_DxIKqeyV2REeICImUdeK_xNaudNlVW25kI8l9WpsBi-vyD5ZvU5MgM
code:


Part 1:
Write an abstract Human class that implements the Human interface above. You?ll need to include the interface in your project. Your abstract Human should conform to the following class summary box:


Class:

Human



Private Instance Variables:

String name, int age, double height, int health, int xPos, int yPos



Public Instance Methods:

constructor

void move(int x, int y)

int getXPos

int getYPos

int getHealth

boolean setHealth

String toString

String getName

void setName

int getAge

boolean setAge

double getHeight

boolean setHeight

void draw (Pen p)



Public Class Variables:

double LOW_HEIGHT, double HIGH_HEIGHT, int LOW_AGE, int HIGH_AGE, int LOW_HEALTH, int HIGH_HEALTH, int NUM_HUMANS



Public Class Methods:

int getNumHumans

void setNumHumans

String getAgeRules

String getHeightRules

String getHealthRules


Part 2:
Implement the Knight and Wizard classes as described in the class summary boxes below.
Class:

Wizard



Private Instance Variables:

int magicka



Public Instance Methods:

constructor

void draw(Pen p)

void castSpell

String toString

boolean setMagicka (int m)

int  getMagicka

boolean equals(Wizard w)

Wizard clone



Public Class Variables:

int LOW_MAGICKA, int HIGH_MAGICKA



Public Class Methods:

String getMagickaRules

Class:

Knight



Private Instance Variables:

String horseName



Public Instance Methods:

constructor

String toString

void draw(Pen p)

void setHorse (String n)

String getHorseName

boolean equals(Knight k)

Knight clone



Public Class Variables:

none



Public Class Methods:

none

Part 3:
Write a test program World, which:
        0. Declares 4 Humans.
        1. Instantiates a Knight
        2. Instantiates a Wizard  and moves it.
        3. Clones the Knight  and changes its name
        4. Checks if the Knight clone is not equal to the original Knight, and if so:
                a) Moves the clone
        5. Clones the Wizard
        6. Checks if the Wizard clone is equal to the original Wizard, and if so:
                a) Moves the clone
        7. Draws both Knights and both Wizards
        8. Prints the total number of Humans living in this World.
        9. Prints a description of all Humans to the console.




Evaluation:
Marks

Part 1:

Abstract Human Class:

Private Instance Variables:

Public Instance Methods:

Public Class Variables:

Public Class Methods:
                             



/3 TI

/7 TI

/2 TI

/2 TI

Part 2:

Knight Class Implementation:

Wizard Class Implementation:


/4 A

/5 A




Part 3:

Declare Humans 

Instantiate Knight and Wizard   

Clone?s Knight and Wizard

Checks and Moves Clones

Draws and Prints World Info     

Header, Commenting 



Challenge:

Draw actual Knights and Wizards!


/1 K

/1 K

/4 K

/4 K

/2 C

/4 C









HumanInterface

Human (abstract)

Knight (concrete)

Wizard (concrete)

Implements
Nathan4102




PostPosted: Fri May 17, 2013 9:56 pm   Post subject: RE:Array questions

It looks like they've written half the thing for you! Interesting though, thanks for posting.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 22 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: