Please can someone do a Sequence Diagram for this code
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Bgame extends JFrame implements ActionListener
Map map;
Location location = new Location();
Player[] player = new Player[2];
int playeri = 0;
Player playerx;
Image boardi = null;
Image bcar = null;
Image gcar = null;
JButton spinButton = new JButton("Spin");
JLabel spun = new JLabel("");
JButton houseButton = new JButton();
JButton carButton = new JButton();
JButton playersButton = new JButton();
JButton bankButton = new JButton();
public Bgame()
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent ev)
dispose();
System.exit(0);
setBounds(1,1,800,600);
getContentPane().setLayout(null);
loadImages();
map = new Map(boardi);
map.setLocation(111,0);
getContentPane().add(map);
createCpan();
player[0] = new Player(bcar,Color.black);
player[1] = new Player(gcar,Color.green);
map.add(player[0]);
map.add(player[1]);
setVisible(true);
playerx = player[playeri];
playerx.spin();
monitor();
private void monitor()
Timer timer = new Timer(1000, new ActionListener()
public void actionPerformed(ActionEvent e)
if (playerx.hasToGo)
//getToolkit().beep();
if (spun.getForeground() == playerx.color)
spun.setForeground(Color.gray);
else spun.setForeground(playerx.color);
return;
if (playerx.hasToSpin)
if (spinButton.getBackground() == playerx.color)
spinButton.setBackground(Color.lightGray);
else spinButton.setBackground(playerx.color);
return;
playeri++;
if (playeri == 2) playeri = 0;
playerx = player[playeri];
playerx.spin();
spun.setText("");
spinButton.setEnabled(true);
spinButton.setBackground(playerx.color);
timer.start();
private void loadImages()
boardi = getToolkit().getImage("Game.gif");
bcar = getToolkit().getImage("blackCar.gif");
gcar = getToolkit().getImage("blueCar.gif");
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(boardi,0);
tracker.addImage(bcar,0);
tracker.addImage(gcar,0);
try {tracker.waitForID(0);}
catch (InterruptedException e){}
private void createCpan()
JPanel pan = new JPanel();
pan.setLayout(null);
pan.setBounds(0,0,110,500);
pan.setBackground(Color.pink);
spinButton.setBounds(10,34,90,30);
spinButton.addActionListener(this);
pan.add(spinButton);
spun.setBounds(10,64,90,30);
pan.add(spun);
getContentPane().add(pan);
public void actionPerformed(ActionEvent e)
if(e.getSource() == spinButton)
int spin = (int)(Math.random()*3+1);
spun.setText("Total spun = "+spin);
spun.setForeground(playerx.color);
spinButton.setBackground(Color.lightGray);
int togo = playerx.location+spin;
playerx.go(togo,location.getX(togo),location.getY(togo));
spinButton.setEnabled(false);
public static void main (String[] args)
new Bgame();
import java.util.*;
public class Location
Space[] spaces = new Space[29];
public Location()
spaces[0] = new Space(1,238,135,"Start Career");
spaces[1] = new Space(2,346,135,"Pay Day");
spaces[2] = new Space(3,417,135,"Rent a Flat Pay 5,000");
spaces[3] = new Space(4,492,167,"Raffle Prize Collect 10,000");
spaces[4] = new Space(5,500,218,"PAY DAY");
spaces[5] = new Space(6,570,269,"STOP Get Married LIFE");
spaces[6] = new Space(7,570,344,"Wedding Reception Pay 10,000");
spaces[7] = new Space(8,517,344,"Extra Tuition Pay 5,000 to Teacter");
spaces[8] = new Space(9,465,344,"Win Quiz Show Collect 95,000");
spaces[9] = new Space(10,407,344,"PAY DAY");
spaces[10] = new Space(11,352,344,"Sponsor Golf Pay 35,000 to Athlete");
spaces[11] = new Space(12,300,344,"Play a family game LIFE");
spaces[12] = new Space(13,246,344,"Buy Furniture PAY 10,000");
spaces[13] = new Space(14,183,344,"Visit in laws LIFE");
spaces[14] = new Space(15,118,344,"STOP Buy a house");
spaces[15] = new Space(16,68,344,"PAY DAY");
spaces[16] = new Space(17,10,356,"Swap Salary Cards with any other player");
spaces[17] = new Space(18,10,412,"Sponsor an athletee Pay 35,000 to Athlete");
spaces[18] = new Space(19,61,412,"Taxes Due PAY Accountant");
spaces[19] = new Space(20,115,412,"Baby Girl LIFE");
spaces[20] = new Space(21,175,412,"Move to a new city PAY 10,000 to Pilot");
spaces[21] = new Space(22,235,412,"Help the homeless LIFE");
spaces[22] = new Space(23,304,412,"Win the Lottery Collect 50,000");
spaces[23] = new Space(24,369,412,"Art auction Pay 20,000 to Artist");
spaces[24] = new Space(25,434,412,"Invest in a theatre PAY 5,000 To Actor");
spaces[25] = new Space(26,489,433,"Taxes Due Pay Accountant");
spaces[26] = new Space(27,518,470,"PAY DAY");
spaces[27] = new Space(28,519,529,"Night School PAY 10,000 To Teacher");
spaces[28] = new Space(29,385,529,"RETIRE");
public int getX(int i)
return(spaces.x);
public int getY(int i)
return(spaces[i].y);
public String getText(int i)
return(spaces[i].txt);
public class Space
int n,y,x;
String txt;
public Space(int n, int x, int y, String txt)
this.n = n;
this.y = y-82;
this.x = x+14;
this.txt = txt;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Map extends JPanel
Image board;
JLabel txt = new JLabel("");
public Map(Image i)
board = i;
setLayout(null);
setSize(board.getWidth(null),board.getHeight(null));
addMouseListener(new MouseAdapter()
public void mouseReleased(MouseEvent m)
System.out.println(""+m);
txt.setBounds(456,04,200,24);
txt.setBackground(Color.lightGray);
txt.setOpaque(true);
add(txt);
public void setText(String s, Color c)
txt.setText(s);
txt.setForeground(c);
public void paint(Graphics g)
super.paint(g);
g.drawImage(board,0,0,null);
paintComponents(g);
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.image.BufferedImage;
public class Player extends JLabel
int location = -1;
Color color;
boolean hasToGo = false;
boolean hasToSpin = false;
Point sloc;
int tox,toy;
int mx,my;
boolean inPlace = false;
public Player(Image car, Color c)
super();
setIcon(new ImageIcon(trans(car)));
color = c;
setBounds(10,10,car.getWidth(null),car.getHeight(null));
if (getWidth() < 1) setSize(40,40);
addMouseListener(new MouseAdapter()
{ public void mousePressed(MouseEvent m)
sloc = getLocation();
mx = m.getX();
my = m.getY();
public void mouseReleased(MouseEvent m)
if (getBounds().contains(tox,toy)) hasToGo = false;
else setLocation(sloc);
inPlace = false;
repaint();
addMouseMotionListener(new MouseMotionAdapter()
{ public void mouseDragged(MouseEvent m)
if (! hasToGo) return;
int x = getX() + m.getX() - mx;
int y = getY() + m.getY() - my;
if (x < 0) x = 0;
if (y < 0) y = 0;
setLocation(x,y);
if (getBounds().contains(tox,toy)) inPlace = true;
else inPlace = false;
repaint();
public void go(int l ,int x, int y)
hasToGo = true;
hasToSpin = false;
tox = x;
toy = y;
location = l;
public void spin()
hasToSpin = true;
public void paint(Graphics g)
super.paint(g);
g.setColor(color);
if (inPlace)
g.setColor(Color.red);
g.fillRect(8,8,16,16);
else
g.setColor(color);
g.drawRect(0,0,36,38);
g.drawRect(1,1,34,36);
public BufferedImage trans(Image img)
int w = img.getWidth(null);
int h = img.getHeight(null);
if (w < 1) w = 40;
if (h < 1) h = 40;
BufferedImage to = new BufferedImage(w,h,BufferedImage.TYPE_4BYTE_ABGR);
to.getGraphics().drawImage(img,0,0,null);
int r1 = to.getRGB(0,0);
for (int x=0; x < w; x++)
for (int y=0; y < h; y++)
if (to.getRGB(x,y) == r1) to.setRGB(x,y,0);
return(to);
To be fair to Phil, the person wasn't asking how to do a sequence diagram, they just wanted one given to them. I'm sure they would have got a more friendly/informative reply if they had actually asked how to do one.
Similar Messages
-
How to generate Sequence Diagrams for existing code
Hi,
I have a web application written in Java/Jsp's. I am looking to generate sequence diagrams automatically for the existing source code using this tool. I am not sure if this is possible using this tool. Can some one please explain me if that is possible using this IDE tool? If so can you please let me know how this can be done?
Any response is greatly appreciated.
Thanks in advance.
VijayHi,
Yes, you can reverse engineer operations and create sequence diagrams using Java Studio Enterprise.
Just right-click on the operation in the UML model that has the source file associated with it, and select "Create Diagram from Selected elements" or "Reverse Engineer Operation".
Thanks! -
I have purchased an app from the store used it for a few days , now it won't open properly .its just a black screen with a circle in bottom right corner with a 1x in it . Anyone know how I can re open this please as I need this app urgent thanks
From the home screen, double click the home button to bring up the Recently used App list. Find the App with the problem and hold your finger on it untl the Apps start to shake. When that happens tap on the (x) on the right side corner of the app to close it.
Tap the home button again to get back to the home screen, and try to open the App again.
If that doesn't work, try resetting the iPad. (there should be no data loss):
Press and Hold the Power and home buttons until the Apple Logo shows up. Ignore any sliders that may appear.
When the iPad turns back on, try opening the App again. -
The DELETE statement conflicted with the REFERENCE constraint "FK_Equipment_Assets". The conflict occurred in database "WorkOrderSystem", table "dbo.Equipment", column 'AssetCode'
ya that's true row is referenced by another table.....but i want the row to referred by another table ,I don't know how to fix it
Actually this is not a C# issue. It is a T-SQl issue.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?forum=transactsql
The above link should be posted.
Per my understanding, first you should
delete the record from the Foreign Table and then after you have to delete the record from the Primary Key table
Hope it helps you.
Best regards,
Kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
I have an early 2011 MacBook Pro which has been running slow for a while. After looking at responses to similar problems I have downloaded and run EtreCheck. Please can someone help me with what it all means.
Thanks in advance.
EtreCheck version: 1.9.15 (52)
Report generated 19 September 2014 08:07:14 GMT+8
Hardware Information: ?
MacBook Pro (13-inch, Early 2011) (Verified)
MacBook Pro - model: MacBookPro8,1
1 2.3 GHz Intel Core i5 CPU: 2 cores
4 GB RAM
Video Information: ?
Intel HD Graphics 3000 - VRAM: 384 MB
Color LCD 1280 x 800
System Software: ?
OS X 10.9.4 (13E28) - Uptime: 0 days 0:4:29
Disk Information: ?
Hitachi HTS545032B9A302 disk0 : (320.07 GB)
S.M.A.R.T. Status: Verified
EFI (disk0s1) <not mounted>: 209.7 MB
Macintosh HD (disk0s2) / [Startup]: 319.21 GB (147 GB free)
Recovery HD (disk0s3) <not mounted>: 650 MB
MATSHITADVD-R UJ-898
USB Information: ?
Apple Inc. FaceTime HD Camera (Built-in)
Apple Inc. BRCM2070 Hub
Apple Inc. Bluetooth USB Host Controller
Apple Inc. Apple Internal Keyboard / Trackpad
Apple Computer, Inc. IR Receiver
Thunderbolt Information: ?
Apple Inc. thunderbolt_bus
Gatekeeper: ?
Mac App Store and identified developers
Kernel Extensions: ?
[not loaded] com.seagate.driver.PowSecDriverCore (5.2.4 - SDK 10.4) Support
[not loaded] com.seagate.driver.PowSecLeafDriver_10_4 (5.2.4 - SDK 10.4) Support
[not loaded] com.seagate.driver.PowSecLeafDriver_10_5 (5.2.4 - SDK 10.5) Support
[not loaded] com.seagate.driver.SeagateDriveIcons (5.2.4 - SDK 10.4) Support
[loaded] com.sophos.kext.sav (9.1.55 - SDK 10.7) Support
[loaded] com.sophos.nke.swi (9.1.50 - SDK 10.8) Support
Launch Daemons: ?
[loaded] com.adobe.fpsaud.plist Support
[loaded] com.microsoft.office.licensing.helper.plist Support
[running] com.sophos.autoupdate.plist Support
[running] com.sophos.configuration.plist Support
[running] com.sophos.intercheck.plist Support
[running] com.sophos.notification.plist Support
[running] com.sophos.scan.plist Support
[running] com.sophos.sxld.plist Support
[running] com.sophos.webd.plist Support
[running] com.trusteer.rooks.rooksd.plist Support
Launch Agents: ?
[loaded] com.divx.dms.agent.plist Support
[loaded] com.divx.update.agent.plist Support
[running] com.sophos.uiserver.plist Support
[running] com.trusteer.rapport.rapportd.plist Support
User Launch Agents: ?
[loaded] com.adobe.ARM.[...].plist Support
[running] com.amazon.music.plist Support
[loaded] com.google.keystone.agent.plist Support
[not loaded] jp.co.canon.Inkjet_Extended_Survey_Agent.plist Support
User Login Items: ?
iTunesHelper
TomTomHOMERunner
AdobeResourceSynchronizer
Dropbox
Internet Plug-ins: ?
FlashPlayer-10.6: Version: 15.0.0.152 - SDK 10.6 Support
DivX Web Player: Version: 3.2.1.977 - SDK 10.6 Support
AdobePDFViewerNPAPI: Version: 11.0.09 - SDK 10.6 Support
AdobePDFViewer: Version: 11.0.09 - SDK 10.6 Support
Flash Player: Version: 15.0.0.152 - SDK 10.6 Support
EPPEX Plugin: Version: 10.0 Support
Default Browser: Version: 537 - SDK 10.9
OVSHelper: Version: 1.1 Support
QuickTime Plugin: Version: 7.7.3
SharePointBrowserPlugin: Version: 14.4.4 - SDK 10.6 Support
iPhotoPhotocast: Version: 7.0 - SDK 10.7
Safari Extensions: ?
Ultimate
Audio Plug-ins: ?
BluetoothAudioPlugIn: Version: 1.0 - SDK 10.9
AirPlay: Version: 2.0 - SDK 10.9
AppleAVBAudio: Version: 203.2 - SDK 10.9
iSightAudio: Version: 7.7.3 - SDK 10.9
iTunes Plug-ins: ?
Quartz Composer Visualizer: Version: 1.4 - SDK 10.9
3rd Party Preference Panes: ?
Flash Player Support
Perian Support
Trusteer Endpoint Protection Support
Time Machine: ?
Skip System Files: NO
Auto backup: YES
Volumes being backed up:
Macintosh HD: Disk size: 297.29 GB Disk used: 160.38 GB
Destinations:
Data [Network] (Last used)
Total size: 2 TB
Total number of backups: 99
Oldest backup: 2012-04-20 17:05:32 +0000
Last backup: 2014-09-18 23:49:25 +0000
Size of backup disk: Excellent
Backup size 2 TB > (Disk size 297.29 GB X 3)
Time Machine details may not be accurate.
All volumes being backed up may not be listed.
Top Processes by CPU: ?
6% InterCheck
5% iCalExternalSync
3% WindowServer
2% CalendarAgent
2% SystemUIServer
Top Processes by Memory: ?
152 MB SophosScanD
147 MB InterCheck
106 MB SophosAntiVirus
66 MB Dropbox
57 MB com.apple.iTunesLibraryService
Virtual Memory Information: ?
161 MB Free RAM
1.55 GB Active RAM
1.41 GB Inactive RAM
902 MB Wired RAM
611 MB Page-ins
0 B Page-outsUninstall Trusteer software
http://www.trusteer.com/support/uninstalling-rapport-mac-os-x
Remove Sophos
https://discussions.apple.com/message/21069437#21069437 -
I have had my iPhone for about a year, and I have a photo file from my old blackberry. When I go to back up my photos, it only backs up the camera roll. How do I back up the other album? The laptop where I had those photos broke, please can someone help.
You're going to have to email those photos to yourself.
-
Hi, I forgot my icloud password and my ipodtouch keeps asking me for my icloud password. When I enter my apple ID password, it will not accept it. I have been trying to find where I can reset my icloud password with no success. Please can someone help?
You reset the iClould password the same way you reset the Apple ID for the email address/account
How do I change or recover a forgotten Apple ID Password?
If you've forgotten your Apple ID Password or want to change it, go to My Apple ID and follow the instructions. SeeChanging your Apple ID password if you'd like more information. -
TS4268 My iphone will not send imessage for normal messages. please can someone help?
My iphone will not send imessage for normal messages. please can someone help?
Hi maccaman82,
If you are having issues sending messages from your iPhone, you may find the following article helpful:
iOS: Troubleshooting Messages
http://support.apple.com/kb/ts2755
Regards,
- Brenden -
Please can someone provide me with Spry Menu Bar Horizontal code for Dreamweaver CS5.5?
Please can someone provide me with Spry Menu Bar Horizontal code for Dreamweaver CS5.5?
Log-in to the Adobe Exchange with your Widget Browser and grab "Spry Menu 2.0."
http://labs.adobe.com/technologies/widgetbrowser/
In Widget browser, style the menu as desired and Save files to your DW Local Site folder.
Nancy O. -
I cant install or uninstall my itunes. I get this error 'the feature you are trying to use is on a network resource that is unavilable' Now ive seen the solutions on here but im using windows 8.1 and none of them work for me. Ive tried all options so please can someone help?
That doesnt work for me. I removed itunes through the windows cleaner method as shown in other posts and re-installed itunes. Now im getting this error
iTunes was not installed correctly. Please reinstall iTunes
Error 7 (Windows error 126)
Also my Microsoft office has stopped working after i deleted Itunes which is really strange.
Can somebody provide me a solution please.... -
I have had to purchase a new computer, as my last laptop died!! I have tried to add music onto my iphone, and my childrens ipod touch's, but its looking like it will clear their memory completely. Please can someone advise me what I need to do. Many thanks.
See iTunes: How to move your music to a new computer
BTW this list os for discussing the list itself. You'll get better response to questiosn you post if you post them to the correct list. I'll ask to have this moved to the iTunes list.
regards -
I am trying to unlock my SIM from my iphone 4s, as I am getting a mesage SIM locked. How do I unlock this?Also I am typing in what I think my code is and it is not working. The voice activation wil not allow me to type in the numbers for some reason. I have turned it off and on about 7 times now. please please please can someone help me?
If you bought the iphone in the US and it is locked to a specific carrier, then you can't use a different sim (from another carrier). Is this your situation?
Otherwise I'm not sure what you mean by "trying to unlock my SIM". In which country did you buy the iphone? Who's your carrier? -
Please can someone tell me how to save a MP3 file from my email on my iPad so I can put it on Faceboo? I use hotmail and please tell me step by step as I am not a tech guru lol. Thankyou
Hi jscher200,
Thank you for your reply, sorry for the VERY late late response, but I have just figured out how to control this separate 'panel'. I find it really useful for monitoring Google Analytics in as it can just sit there running. It does have its limitations, as it's a limited size (you can't expand it to full screen view), so you can only ever see a vertical section of a website and need to scroll to look to the right or left, but I have the live view of people accessing my website running on there and if the numbers start racking up at any time, I can scroll to look and see what pages they are accessing, where they've been referred from, etc.
To get it to work, you save a website address in the Bookmarks Toolbar and when you can see it sitting on the toolbar at the top of the screen with its little icon, right click on it then click 'properties', then tick the box 'Load this bookmark in the sidebar'. The next time you click on this bookmark to open the website, it will load in this sidebar, which looks like a separate 'window' but is immovable. You can only have one sidebar application running at a time, but can change it by right clicking on the bookmark you want to load in there and it will then change to that one next time you click on that bookmark.
I hope this might be useful to others, as I asked for help with this on loads of forums and not one person knew that this existed - even really skilled techies! -
Trying to re-install iTunes and the message "Apple mobile device failed to start. Verify that you have sufficient privileges to start system services." But I don't know what to do? Please can someone help, I'm not the most technologically advanced person.
Go to Control Panel > Add or Remove Programs (Win XP) or Programs and Features (later)
Remove all of these items in the following order:
iTunes
Apple Software Update
Apple Mobile Device Support (if this won't uninstall move on to the next item)
Bonjour
Apple Application Support
Reboot, download iTunes, then reinstall, either using an account with administrative rights, or right-clicking the downloaded installer and selecting Run as Administrator.
The uninstall and reinstall process will preserve your iTunes library and settings, but ideally you would back up the library and your other important personal documents and data on a regular basis. See this user tip for a suggested technique.
Please note:
Some users may need to follow all the steps in whichever of the following support documents applies to their system. These include some additional manual file and folder deletions not mentioned above.
HT1925: Removing and Reinstalling iTunes for Windows XP
HT1923: Removing and reinstalling iTunes for Windows Vista, Windows 7, or Windows 8
tt2 -
unable to update to ios 5 on windows 7. please can someone help me i have tried everything? i deleted itunes and downloaded the new version when i plug my iphone 4 in it does a back and then I then everything runs normal and it extracts and then i get an error code at the end 3197. had the iphone for two months and its new.
Please can somene help me, i am currently on version 4.3.3 (8J2)
Modem Firmware 04.10.01followed someones instructions and it has worked ios 5 is now working on my iphone 4
Maybe you are looking for
-
Old messages gone in Mail.app, but still present via .Mac Webmail.
Hi. I have a .Mac account set up as IMAP in the Mail application and cannout figure out where all my old messages went. I have tried everything- there are no rules that delete them, there are no other computers or anything else involving POP in the s
-
Why does Contribute generate extraneous HTML code?
Why does Contribute CS4 generate so much extraneous HTML code that is either redundant or conflicts with styles specified in our style sheet? Below are examples of what we've encountered in the first two weeks of using the product. It seems that, i
-
Dear SAP Gurus, My client where Funds Management has been implemented, has a specific requirement of assigning budget to Vendors. In our case we have treated all employees as vendors. Some of the employees(vendors) get grants for specific projects an
-
After installing Lion, Safari is Not Working
Problem: Trying to access my website http://www.johnrollow.com I get this error message. Not Found The requested URL / was not found on this server Apache Server at www.johnrollow.com Port 80 I get the same error message from both Safa
-
Every time i try to play games it blinks and go to home screen what do i do
every time i try to play a game it blinks the game and the go to home screen what to do