Football Manager - Find Out Optimal First Eleven Amongst 25 Or 30 Players
Nov 26, 2014
I am looking into making a program, that will find out the optimal first eleven (in football or soccer for americans) amongst 25 or 30 players. This is going to apply for a computer game: "Football manager 2015"
I was thinking one class would be the player class that is going to have the variables:
player_number (unique) integer
name string
position (there are eleven positions)
position_rating for each position capable of playing
constructor would be add_player(int number, string name)
and a method would be add_position(position, position_rating)
one player can have more than one positions
another class would be the position
position name (unique) string
that's all I can think of now.
the main class would do a loop
starting with a random or defined position it would do all combinations of every single player into each position.
For example it could start with center forward position. There are 5 available players for that position. Lets say the program picks the first player that is also capable of playing in wide position. If the player is picked for center forward he is not avaialable for wide position.
Then the program would move to the wide position and lets say there are 4 players available. It would pick one.
Once 11 players are selected it would add the 11 ratings.
and start over for a different player in center forward position.
at the end of all loops it would print out the 11 players into their respective positions that got the best score.
I have been trying to make a football league table in java based on text input and output. I want to to know if i have done task 1 right if not could you
Task 1. Design and implement classes SportsClub (abstract class), FootballClub.Classes should include appropriate methods and hold information about name of the club,its location and various statistics about the club. FootballClub should include statistics such as how many wins, draws and defeats an instance of it has achieved in the season, the number of goals received and scored. The number of points that a club currently has, and number of matches played.
Task 2. Implement a class PremierLeagueManager which extends interface LeagueManager. PremierLeagueManager class maintains a number of football clubs which play in the premier league. The class should create a menu based on text input and give the user the choice of:
• Create a new football club and add it in the premier league. • Delete (relegate) an existing football club from the premier league. • Display the various statistics for a selected club. • Display the Premier League Table
Here is my code for Task 1:
public abstract class SportsClub { int position; String name; int points; int wins; int defeats; int draws; int totalMatches;
This specific assignment requires me to write a program that calculates the total sales after each football game. There are 4 types of tickets: box, sideline, premium, and general admission. After each game, data is stored in a file... then output the number of tickets sold and total sale amount. Format your output with 2 decimal places.
Okay I know there is a I/O section and wasnt sure where to post this. I need some insight on how to use file input and output as well ... Here is my program:
import javax.swing.JOptionPane; import java.text.DecimalFormat; public class ticketsSold { public static void main(String[] args) { String BoxSeat; String SideLine;
My assignment is for a game where there is a board of colors and each player draws a color and moves to that position on the board. It will then output how many cards total in the game it took whichever player to win. If no winner it outputs the number of cards that none won by going through. I attached the file that corresponds with my code.
This is the desired output:
Player 1 won after 7 cards. Player 2 won after 8 cards. No player won after 8 cards. Player 2 won after 4 cards. No player won after 6 cards. Player 2 won after 8 cards. Player 1 won after 4 cards. Player 2 won after 8 cards. Player 1 won after 1 cards. No player won after 200 cards. Player 4 won after 100 cards.
import java.io.*; import java.util.Scanner; public class ProgrammingAssignment1 { /** * @param args the command line arguments */ public static int players; public static int cards; public static int boardlength; public static String board;
[Code] .....
The output that I get is:
Player 1 won after 3 cards. Player 2 won after 8 cards. No player won after 8 cards. Player 1 won after 3 cards. No player won after 6 cards. Player 2 won after 8 cards. Player 1 won after 3 cards. Player 2 won after 8 cards. Player 1 won after 1 cards. No player won after 200 cards. Player 4 won after 100 cards.I guess I'm supposed to set the playerPos[] to -1, but I'm unsure how.
So I'm working on this game for a school project and I have 2 problems
1.I do not know how to display the players score in the panel 2.Every single time the console reads the second button I click on as a 0 instead of the number underlining it
import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.border.*; public class Matchgame extends JPanel implements ActionListener { private final JPanel Brd = new JPanel(new BorderLayout(3, 3));
I'm in the process of building an algorithm for a leaderboard for my game, but now I'm stuck.
- It is a two-player game. - The leaderboard is supposed to display the top 5 players. - Scores will be saved to an external .txt file as a reference.
Also, may I add that I still cannot decide if I should only consider the winner's score for the leaderboard, or also the loser's.
For example:
Player 1 is Juliet. Player 2 is Romeo.
At the end of the match, Juliet's score is greater than Romeo's.
Should I only evaluate Juliet's score for the leaderboard, or both of their scores? As of now my algorithm considers only the winner's score.
As of the moment I'm also only thinking of using JLabel to display the scores, but I'm not sure if this is the most efficient way to do it. I'm considering JTable.
So here's my current algorithm:
1) When the user starts a new match/returns to menu/exits game: (I provided 4 options: new game (scores remain but the board is reset), new match (everything is reset), menu, and exit.)
public class Game { //This class also holds the code for the operation of the game if (event.getSource() == newmatch)//or menu or exit { if (p1score != 0 || p2score != 0) { Leaderboard x;
[Code] .....
3) The next step which is I'm highly unsure of is to create an ArrayList for the scores (I'm missing the part about the player's name because well I'm not sure as well how I will approach it) and then sort it, but the problem after that would be how to make the score agree with the player's name, if you get what I mean.
Like for example the scores are:
Anna = 1 Pamela = 5 Gabby = 3 Sorted: 5, 3, 1
Pamela has the highest score, but how will I be able to display her name together with her score?
4) I have a checker which determines if the ArrayList of scores is empty, and if it is, it will automatically display the player's name and score (this is for the first pair of players).
It's something like this:
if (board.isEmpty()){ label1.setText(winnername); scorelabel1.setText(winnerscore); } else { // }
There's a whole lot of buzz going on and now I don't know how I should proceed.
I want to create a TASK MANAGER for windows OS using java. Of course i am not expecting any code snippets, that is, what are the classes to be included and moreover HOW to do it.
Create a frame with ten buttons, labeled 0 through 9 (Hint: You may create an array of 10 buttons). To exit the program, the user must click on the correct three buttons in order, something like 7-3-5. If the wrong combination is used, a JOptionPane message ““Wrong, try again.” will be displayed. You may use GridLayout Manager to arrange the buttons nicely. My coding :
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Combination extends JFrame { private JButton[] numbers= {new JButton("0"),new JButton("1"), new JButton("2"),new JButton("3"), new JButton("4"),new JButton("5"), new JButton("6"),new JButton("7"), new JButton("8"),new JButton("9")};
[code]....
Ok so I don't have any error in this. Only issue I have is my loop goes infinite. I can click on any numbers. I want to limit it for upto three numbers and if they are wrong output as wrong numbers. and If they press right number I want Correct number as output.
Am trying to develop a web application, and am using the Entity Manager. The web application involves users posting data to the database. How do I incorporate the entity manager together with the prepared Statement functionality to avoid users corrupting the database with SQL tags?
If I have EJB database session beans, when the content of the database changes, does the information on the web page get automatically updated dynamically on the client machine?
For example, say I have I BoxLayout with a few JButtons in it. How could I make it such that I could drag a JButton such that it could be in front or behind the others?
I've thought about using ComponentMover and just switching to a null layout right before moving it and switch it back right after like bellow, but I'm not sure how to make it keep the change in order.
import java.awt.LayoutManager; import java.awt.event.MouseEvent; public class LayoutComponentMover extends ComponentMover { private LayoutManager layout;
I have followed the Java tutorial on JAAS Authentication and Authorization. All the sample code in the tutorials works fine also when running under a security manager. Now I am trying to modify the LoginModule class, so that it uses a password file to look up users and passwords, but as soon as I try to run the code under a security manager, I get a Security Exception. I suppose it has something to do with the code havent been granted any access to read the password file? So I tried to add this to the policy file:
grant codebase "file:./sample/module/-" { permission java.io.FilePermission "sample/module/passwords.txt", "read"; };
It didn't do any difference. why I get this Security Exception?
The only difference from my code to the tutorial code, is that I have added the lines:
I finish reading The EntityManager Interface in JEE tutorial. I know I can use container manager entity manager in EJB, but I want to explore how to use application managed entity manager in EJB.
Can I use application managed entity manager in EJB (container management JTA transaction is used)? Where do I should close entity manager if can?
The following is an example from JEE tutorial, but didn't find where to calose entity manager. and can I create mutiple EntityManagerFactory objects and Entity Manager objects to use them in a JTA transaction?
I read JEE6 doc and confused with : Does container managed entity manager (injected by PersistenceContext annotation) is thread-safe in stateless session bean in multiple-thread env?
See code below, if there are 2 requests to stateless sesion bean in 2 concurrent threads , is it using same Entity Manager Instance or not?
@Stateless(name = "HRFacade", mappedName = "HR_FACES_EJB_JPA-HRFacade-HRFacade") public class HRFacadeBean implements HRFacade, HRFacadeLocal { @Resource SessionContext sessionContext;
i am trying to store a number of different value cards for a number of players. E.g there can be 2 , 4 or more players and each player can have any number of cards.
I have decided to use an arraylist for cards and tried using an array for players. But after coding and reading some information online, i realised that it is not possible to have an array of arraylist.
I'm trying to find a specific file that already exists on the computer. I want to find that file and zip it. don't get sidetracked with whether or not the file exists, because I'm sure it does on my local machine and TDD will address that what-if scenario later.
My code and JUnit is below. Since its not finding the file, I assume I must be formatting 'path' wrong. I wonder if I'm even on the right track logically.
private ZipParameters zp = new ZipParameters(); private ZipFile zipFile; public ZipFile createZipFile(File f, String path) throws ZipException{ zipFile = new ZipFile(path); zp.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); zp.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
i want to write a program have a array 2d like that :
int array [][] = new int [3][3]
after that the user input value by using scanner then give summation of each column in matrix , i wrote this one
Java Code:
class MatrixSum{ public static void main(String[] args) { int matrix1[][]= {{7,8,9},{1,5,2}}; int matrix2[][]= {{1,6,4},{2,7,3}}; System.out.println("Number of Row= " + matrix1.length); System.out.println("Number of Column= " + matrix1[1].length); int l = matrix1.length; System.out.println("Matrix 1 : "); for(int i = 0; i < l; i++) {
[code]...
but i want to change that the user input the value by using scanner.
How can I find the DPI of an image? The following code tells me the size of the image in pixels which I want to convert to millimetres. When I have looked at conversions I can find - "mm = (pixels * 25.4) / dpi" but how do I find out the DPI?
public class NewMain { /** * @param args the command line arguments * @throws java.io.IOException */ public static void main(String[] args) throws IOException { String filename = null; BufferedImage bimg = ImageIO.read(new File("testimage.jpg")); int width = bimg.getWidth();
I am having trouble compiling my simple java program, i keep having this "cannot find symbol"Untitled.jpg but the ODD thing is when i tried to run my code through online java compiler like Ideone.com it compiles perfectly fine. "Check it here".is it because of my jdk? I use the latest jdk 8. and the book I'm following is "Head First Java"..here's my code
My assignment is to create an ObjectOutputStream object mapped to a binary output file named "ItemRecord_binary.txt". So far I've created a ItemRecord class with a constructor with getters and setters and a override toString method. It compiled. This ItemRecordReport class does not compile because of a can't find symbol error. Here is the code:
import java.io.*; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.Scanner; public class ItemRecordReport { private ObjectOutputStream output;
(Square numbers) Find the first ten square numbers that are greater than Long.MAX_VALUE . A square number is a number in the form of n 2 . For example, 4, 9, and 16 are square numbers. Find an efficient approach to run your program fast.
I found two ways of solving this but i think both are way inefficient :
-A square number can be divided in lesser square numbers :
what's the square of 36 ? 36 is 2 * 3 * 2 * 3 => 4 * 9 => square is 2 * 3
-second option is to estimate a number and increase it or decrease it based on how close that number * number is to the BigInteger starting number , as as it gets closer the delta gets smaller until it gets to 1