01.02.2013 Views

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

working with branches<br />

Fixing Version 1.0...for real this time.<br />

When we had everything in the trunk, we got an error trying to commit old<br />

patched code on top <strong>of</strong> our new code. Now, though, we’ve got a tag for version<br />

1.0 and a branch to work in. Let’s fix Version 1.0 in that branch:<br />

1<br />

We’ll put<br />

this in the<br />

BeatBoxV1<br />

directory<br />

this time.<br />

2<br />

208 Chapter 6<br />

First, check out the version-1 branch <strong>of</strong> the BeatBox code:<br />

File Edit Window Help History<br />

hfsd> svn checkout file:///c:/Users/Developer/Desktop/SVNRepo/BeatBox/<br />

branches/version-1 BeatBoxV1<br />

A BeatBoxV1\src<br />

A BeatBoxV1\src\headfirst<br />

A BeatBoxV1\src\headfirst\sd<br />

A BeatBoxV1\src\headfirst\sd\chapter6<br />

A BeatBoxV1\src\headfirst\sd\chapter6\BeatBox.java<br />

A BeatBoxV1\src\headfirst\sd\chapter6\MusicServer.java<br />

Checked out revision 9.<br />

hfsd><br />

These revisions numbers stop meaning as much, because<br />

we’re using tags to reference revisions instead <strong>of</strong><br />

revision numbers.<br />

Now you can fix the bug Bob found...<br />

We’re working here, in the<br />

version-1 branch.<br />

// ... the code below is from BeatBoxFinal.java buildGUI() ...<br />

JButton sendIt = new JButton("sendIt");<br />

sendIt.addActionListener(new MySendListener());<br />

buttonBox.add(sendIt);<br />

JButton sendPoke = new JButton("Send Poke");<br />

sendPoke.addActionListener(new MyPokeListener());<br />

buttonBox.add(sendPoke);<br />

userMessage = new JTextField();<br />

buttonBox.add(userMessage);<br />

// ... this is new code we need to add to BeatBoxFinal.java ...<br />

public class MyPokeListener implements ActionListener {<br />

void actionPerformed(ActionEvent a) {<br />

// We'll create an empty state array here<br />

boolean[] checkboxState = new boolean[256];<br />

try {<br />

Notice we didn’t need to specify a revision here.<br />

The branch is a copy <strong>of</strong> the version 1.0 code.<br />

writeObject(POKE_SEQUENCE);<br />

writeObject(checkboxState);<br />

} catch (Exception ex) { System.out.println("Failed to poke!"); }<br />

BeatBox.java<br />

public<br />

out.<br />

out.<br />

trunk<br />

version-1<br />

Download at WoweBook.Com<br />

This time, we’re working on code<br />

from the version-1 branch.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!