Previous Tip  |  Next Tip  |  Design Tips   | [Bill's Home]

Who needs Object-oriented methods?

Object-orientation is one of the most fundamental issues in computing, and every student should understand its usage. Network Engineers should be able to view networks as a collection of abtract objects, each with properties, and in understanding distributed software objects. Software Engineers obviously need to understand it in order to produce efficent programs. Multimedia developers also need to understood it, in order to write efficient media content. Flash 5 and MX now allow object-orientation, where data can be properly modelled. A good example of this is in creation of the questions for the Who Wants to be a Network-aire? quiz. For this a data structure is setup (as given below in bold) which represents each question, for the question itself (.q), answer A (.a), and so on.

function myquests(q,a,b,c,d,ans)
{
this.q=q;
this.a=a;
this.b=b;
this.c=c;
this.d=d;
this.ans=ans;
}

var question1 = new Array();
var question2 = new Array();
var question3 = new Array();
var question4 = new Array();
var question5 = new Array();
var question6 = new Array();
var question7 = new Array();
var question8 = new Array();
var question9 = new Array();
var question10 = new Array();

question1[0]=new myquests("What does IP stand for?","Inkwell Protocol","Igloo Protocol","Iggy Protocol", "Internet Protocol","D");
question1[1]=new myquests("How many computers are there on the Internet?","10","1000","10,000","Over 100 million","D");
question1[2]=new myquests("What does WWW stand for?","World Wide Web","Wild West Wonder","Wiggle Waggle Wopple", "Where's Wally Where?", "A");
question1[3]=new myquests("What does bps stand for?","Best Possible Section","Bits Per Second","Beat People Silly","Bring Polly Silly","B");
question1[4]=new myquests("What does RFC stand for?","Rangers Football Club","Request For Comment","Rangers For the Cup","Rangers Are Cool","B");
question1[5]=new myquests("Who invented logarithms?","Jimmy Napier","Jack Napier","John Napier","Oli Napier","C");
question1[6]=new myquests("Which bridge is the Cisco logo based on?","Golden Gate Bridge","Forth Road Bridge","Kincardine Bridge","South Bridge Edin","A");
question1[7]=new myquests("Which of the following is not taught on CNDS?","Needlework","Ethernet","Security","Wireless","A");
question1[8]=new myquests("Which of the following is not a Napier campus?","Edinburgh Castle","Merchiston","Craiglockhart","Craighouse","A");
question1[9]=new myquests("What does TCP stand for?","Termite Castle Pool","Tandori Curry Pasta","Temporary Cat Polish","Transport Control Protocol","D");
question1[10]=new myquests("What are the main functions of the network layer?","Addressing and routing","Addressing and session control","Routing and networking","Network tolopogy and addressing","A");
question1[11]=new myquests("What network address is used by Novell NetWare?","Postal address","E-mail address","Public address","IPX address","D");
question1[12]=new myquests("Which organisation developed the OSI model?","ISO","Marks & Spencer","Edinburgh District Council","SFA","A");
question1[13]=new myquests("Which best defines a WAN?","The number 1 (in Scotland)","Connects a large geographic area","NAW, in reverse","Where Any Network?","B");
question1[14]=new myquests("Which one of the following is not an Edinburger?","Sir Arthur Conan Doyle","Robert Louis Stevenson","Sean Connery","Nelson Mandela","D");
question1[15]=new myquests("Which one of the following is not an Edinburger?","David Hume","Muriel Spark","Sir Walter Scott","Michael Jordan","D");
question1[16]=new myquests("What was the first artifical satellite?","Telstar","Sputnik 1","Explorer-1","Apache-1","B");

 

Question1 now is an array with five properties. This then can be used in the main frame with:

if (level==1)
{
i=random(questions_level_1);

question=question1[i].q;
questa=question1[i].a;
questb=question1[i].b;
questc=question1[i].c;
questd=question1[i].d;
correct=question1[i].ans;

}
else if (level==2)
{

i=random(questions_level_2);

question=question2[i].q;
questa=question2[i].a;
questb=question2[i].b;
questc=question2[i].c;
questd=question2[i].d;
correct=question2[i].ans;

}

This gives: