Capítulo III. Publicación 1
III.1. Resumen de la publicación
TECHNICAL OVERVIEW
JAVA LANGUAGE:
Java is an innovative programming language that has become the language of
choice for programs that need to run on a variety of different computer systems. First of all, Java enables you to write small programs called applets. These are programs that you can embed in web pages to provide some intelligence. Being able to embed executable code in a web page introduces a vast range of exciting possibilities. Instead of being a passive
presentation of text and graphics, a web page can be interactive in any way that we want.
Java’s support for the Internet and network-based applications generally doesn’t end with applets. For example, Java Server Pages (JSP) provides a powerful means of building a server application that can dynamically create and download HTML pages to a client that are precisely customized for the specific request that is received. Of course, the pages that are generated by JSP can themselves contain Java applets. Java also allows us to write large-scale application programs that we can run unchanged on any computer with an operating system environment in which Java is supported. This applies to the majority of computers in use today. We can even write programs that will work both as ordinary applications and as applets.
The most important characteristic of Java is that it was designed from the outset to be machine independent. We can run Java programs unchanged on any machine and operating system combination that supports Java. The next most important
characteristic of Java is that it is object-oriented.
APPLETS:
Applets are small applications that are accessed on an Internet server, transported over the Internet, automatically installed, and run as part of a Web document. After an applet arrives on the client, it has limited access to resources, so that it can produce an arbitrary multimedia user interface and run complex computations without introducing the risk of viruses or breaching data integrity.
23
CODING
STYLESHEET
/*<applet code="RandomGen2" height=800 width=1500>
*</applet>*/
public class RandomGen2 extends Applet implements ActionListener
Font f=new Font("SansSerif",Font.BOLD,12);
setFont(f);
setBackground(Color.white);
btnGen = new Button("ROLL THE DICE");
btnGen.addActionListener(this);
setLayout(new BorderLayout());
btnpanel=new Panel();
btnpanel.add(btnGen);
add(btnpanel, BorderLayout.SOUTH);
//Array to store lucky numbers array = new int[] {0,0,0,0,0,0};
24
//Color for each lucky number
charColor=new Color[] {Color.red, Color.orange, Color.green, Color.pink, Color.blue, Color.black };
}
public void paint(Graphics g) {
g.setColor(Color.blue);
g.fillRect(74,202,64,64);
g.fillRect(10,330,64,64);
g.setColor(Color.yellow);
g.setColor(Color.yellow);
g.drawString("93",468,20);
g.drawString("56",276,276);
g.drawString("19",84,522);
g.drawArc(30, 40, 300, 300, 0, 75);
g.drawArc(30, 40, 300, 300, 0, -75);
g.drawArc(100,100,400,400,0,-75);
g.drawArc(305,486,160,130,190,-75);
int h = 30;
Font f=new Font("SansSerif",Font.BOLD,15);
g.drawString("SNAKES & LADDERS",150,680);
//Fonts for title
Font font = new Font("Verdana", Font.BOLD , 15);
g.setFont(font);
g.setColor(Color.red);
g.drawString("CURRENT NUMBER ON THE DICE", 670, h);
//lines to draw borders g.drawLine(660,10,960 ,10);
g.drawLine(660,10,660,210);
g.drawLine(960,10,960,210);
//Vertical distance from title to numbers h= h + 100;
g.drawString(" "+player1_score,760,230);
g.drawString(" "+player2_score,760,260);
g.drawString(" " +win,760,300);
g.drawString(" "+win1,760,330);
g.drawString(" "+win2,760,360);
34
}
public void actionPerformed(ActionEvent ev) {
int exist=0;
int n =1;
turn++;
//initialize rnd with current system time Random rnd = new Random();
//generate the first number
int i = Math.abs(rnd.nextInt() % 7);
//If number is 0 keep generate numbers until it is not 0; there is no 0 in Lottery
while(i==0)
public void current_score(int i,int turn) {
//player1
if (turn%2==0 && (player1_score+i)<=100 && win!="GAME OVER")
{
//to enter the board
if(i==6&& player1_score==0) player1_score=player1_score+i;
else if(i<=6 && player1_score>0) player1_score=player1_score+i;
player1_score=player1_score+57;
else if(turn%2!=0 &&(player2_score+i)<=100 && win!="GAME OVER")
{
//to enter the board
if(i==6&& player2_score==0) player2_score=player2_score+i;
else if(i<=6 && player2_score>0) player2_score=player2_score+i;
if(player1_score==100)
win1=" CONGRATULATIONS!!!!!!! PLAYER1 WINS";
else
win2=" CONGRATULATIONS!!!!!! PLAYER2 WINS";
} } }
37
TESTING
UNIT TESTING
It is a method of testing that verifies the individual units of source code.
A unit is the smallest testable part of an application.
This is also known as “module testing”.
Implementation in our project
After writing code of each module like design of game board, rolling of dice, movement of dice and user interface, we separately checked whether the result generated is correct or not.
We have applied these testing on a set of dummy moves for testing purposes.
Each module is tested a large number of times till the integration is done.
INTEGRATION TESTING
‘Integration Testing’ (sometimes called Integration and Testing, abbreviated I&T) is the phase of software testing in which
individual software modules are combined and tested as a group.
Implementation in our project
This testing has been done in our project with sample moves by rolling the dice and checking the moves of various numbers appearing on the dice.
We have taken input modules which have been unit tested and grouped them in large scale tests as defined in an integration test plan to those aggregates, and then the output is obtained as an integrated system, ready for system testing.
39
SYSTEM TESTING
System testing of software or hardware is testing conducted on a complete, integrated system to evaluate the system’s compliance with its specified requirements. System testing falls within the scope of black-box testing, and as such, should require no knowledge of the inner design of the code or logic.
Implementation in our project
A series of testing are done before the system is ready for accepting the final test. Each of the modules like design of game board, rolling of dice, movement of dice and user interface, have been tested on different compatible systems.
Effort was done to maximize the number of iterations of all modules testing to remove all the errors.
VALIDATION TESTING
After integration testing and system testing, software is completely assembled as a package, interfacing errors has been uncovered and corrected
A final series of software tests, validation begins.
RECOVERY TESTING
In software testing, we have preceded the recovery testing to test how well the software is able to recover from crashes,
hardware failures and other similar problems.
Implementation in our project
We have practically performed this testing by running our software on the systems heavily loaded with running processes, a desktop running on UPS and a laptop running on battery power.
The result was success in every case.
41