Help on merging classes

hi i have 3 classes, player, card, test
player class:
public class Player {
String name;
public String getName() {
return name;
public void setName(String playerName) {
name = playerName;
}card class:
import java.util.*;
public class card {
     public static int[][] createGridOfNumbers(int nRows, int nCols) {
     Random randomNumberGenerator = new Random();
     int[][] grid = new int[ nRows ][ nCols ];
     for (int nRow = 0; nRow < nRows; nRow++) {
     for (int nCol = 0; nCol < nCols; nCol++) {
     int nMinRandomNumber = nCol * 10 + 1;
     int nMaxRandomNumber = (nCol + 1) * 10;
int randomNumber = randomNumberGenerator.nextInt(nMaxRandomNumber - (nMinRandomNumber - 1)) + nMinRandomNumber;               
if (nRow > 0) {
boolean foundUniqueNumber = false;
do {
boolean isNumberInGrid = false;
for(int nCheckRow = 0; nCheckRow < nRow; nCheckRow++) {
  if(randomNumber == grid[ nCheckRow ][ nCol ]) {
                               isNumberInGrid = true;
break;
                                   if(isNumberInGrid) {
                                 randomNumber = randomNumberGenerator.nextInt(nMaxRandomNumber - (nMinRandomNumber - 1)) + nMinRandomNumber;
                                 foundUniqueNumber = false;
          } else {
                                 foundUniqueNumber = true;
     } while(!foundUniqueNumber);
     grid[ nRow ][ nCol ] = randomNumber;
          return grid;
     public static void displayGrid(int[][] grid) {
for (int nDash = 0; nDash < grid[ 0 ].length * 6; nDash++) {
             System.out.print("-");
          System.out.println();
          for (int nRow = 0; nRow < grid.length; nRow++) {
     for (int nCol = 0; nCol < grid[ 0 ].length; nCol++) {
          System.out.print("| ");
          if (grid[ nRow ][ nCol ] < 10) {
             System.out.print(" ");
     System.out.print(grid[ nRow ][ nCol ] + " |");
     System.out.println();
for (int nDash = 0; nDash < grid[ 0 ].length * 6; nDash++) {
             System.out.print("-");
     public static void main(String[] arg) {
          int[][] grid = createGridOfNumbers(4, 9);
          displayGrid(grid);
}test class:
public class test{
     public static void main(String[] args) {
String playerName;
     System.out.println("Welcome ty ");
     System.out.println("Please enter your name");
playerName = Console.readFromKeyboard();
            Player player = new Player();
            player.setName(playerName);
           System.out.println("Hello " + player.getName());
}i managed to get the player code working in the test class, but im not sure on how to move the card class into the test class. i tired using import but that didnt work, could someone advise me on a option for this.

well this is new code for the test class, the grid says that it cant be resolved, shouldnt the '.card' resolve that, or have i put it in wrong?
public class test{
     public static void main(String[] args) {
String playerName;
     System.out.println("Welcome ty ");
     System.out.println("Please enter your name");
playerName = Console.readFromKeyboard();
            Player player = new Player();
            player.setName(playerName);
           System.out.println("Hello " + player.getName());
             card.createGridOfNumbers(4, 9);
             card.displayGrid(grid);
}

Similar Messages

  • RE: (forte-users) Help on 'The class has been voided andcannot be insta

    PB Solved.
    The symtom was that my 'windows' plan that I distrubute call
    the StartMethod of a class defined higher in the hierarchy,
    and I had to specify that plan as direct supplier plan of my
    new project for the 'voided' not to happen.
    cheers
    j-p
    -----Message d'origine-----
    De: Jean-Paul Gabrielli [mailto:Jean-Paul.Gabriellisema.fr]
    Date: mercredi 5 juillet 2000 12:08
    &Agrave;: Klerk, Theo de
    Objet: RE: (forte-users) Help on 'The class has been voided and cannot
    be instanciated' plz
    the issue is as follows:
    I distribute a plan A
    I want to rename the plan,
    and create a plan B that has A as supplier.
    Distributing B wor'ks
    Running it fails with that issue.
    Actually I recreated supplierplans in B as they were defined in A,
    and the problem disappeared.
    thansk for your time
    j-paul
    -----Message d'origine-----
    De: Klerk, Theo de [mailto:Theo.de.Klerkcompaq.com]
    Date: mardi 4 juillet 2000 22:31
    &Agrave;: 'Jean-Paul.Gabriellisema.fr'
    Objet: RE: (forte-users) Help on 'The class has been voided and cannot
    be instanciated' plz
    Jean-Paul,
    It would help if you have a bit more description around thesituation when
    this error happens.
    Could it be you have two service objects that refer to each other
    while the
    partition is still starting up? (SO's are not supposed to talk to
    each other
    during partition startup).
    Or was the partition up and running?
    Has the service object been in existence and used before itbecame voided?
    Is the partition compiled or interpreted?
    Theo de Klerk
    Architecture & Application Integration
    Professional Services
    Compaq Computer Corp. - the Netherlands
    PGP Fingerprint: 5A70 DD56 F3BA FE04 9DCA 1ACE 8581 0A2F F057 FA6E
    -----Original Message-----
    From: Jean-Paul Gabrielli [mailto:Jean-Paul.Gabriellisema.fr]
    Sent: Tuesday, 04 July, 2000 18:17
    To: Forte-Users
    Subject: (forte-users) Help on 'The class has been voided and
    cannot be
    instanciated' plz
    Hi,
    Here's the stack I get:
    SYSTEM ERROR: Failed to create service object
    BOS.MyServicesMgrSO.
    Class: qqsp_ResourceException
    Error Time: Tue Jul 4 18:05:07
    Exception occurred (locally) on partition "BC_cl0_Part3",
    (partitionId =
    AF3B67A0-3335-11D4-BE9D-963C5A7FAA77:0x224, taskId =
    [AF3B67A0-3335-11D4-BE9D-963C5A7FAA77:0x224.6]) in application
    "BC_cl0", pid 10328 on node MyServerin environment
    CentralEnv.
    SYSTEM ERROR: The class MyServericesMgr has been voided and cannot
    be
    instantiated in this partition.
    Class: qqsp_UsageException with ReasonCode: SP_ER_INVALIDSTATE
    Error #: [201, 14]
    Detected at: qqlo_VoidedClassException at 1
    Error Time: Tue Jul 4 18:05:07
    Exception occurred (locally) on partition
    "BC_cl0_Part3",
    (partitionId =
    AF3B67A0-3335-11D4-BE9D-963C5A7FAA77:0x224, taskId
    =
    [AF3B67A0-3335-11D4-BE9D-963C5A7FAA77:0x224.6]) in
    application
    "BC_cl0", pid 10328 on node MyServer in
    environment
    CentralEnv.
    aud Tue Jul 4 18:05:07 : Shutting down partition due to
    failure of this
    partition.
    aud Tue Jul 4 18:05:07 : Shutting down partition as requested.
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe,
    send in a new
    email the word: 'Unsubscribe' to:
    forte-users-requestlists.xpedior.com

    Hi Sylvain
    Try using window.smallIconImage =
    ImageData(<TitleBarIcon>.ImageValue) ;
    This should work.
    Jairaj Rampershad
    System Concultant
    --- Sylvain_Por&eacute;e <Sylvain.Poreesophia.sema.fr>
    wrote:
    Hi Forte Gurus,
    I have tried to set an icon using this statement :
    window.SmallIconImage =
    aIconFile.<TitleBarIcon>.imagevalue;
    where <TitleBarIcon> is a PictureGraphic in my
    window workshop.
    I have tried 16*16 16 colours as well as many other
    arrangements. It does
    not work. I use windows NT.
    Any ideas ?
    Thanks
    Sylvain
    PS : For info (forte help):
    SmallIconImage
    Data Type ImageData
    Source Class Window
    Settable? Yes
    The SmallIconImage attribute (ImageData) provides
    the small icon to be used
    when the window is iconized, for example, in the
    task bar. The image size
    for a small icon should be 16 by 16 pixels. Although
    the image will be
    scaled if you provide one of a different size, for
    best results, we
    recommend that you create your icons in the same
    size in which they will be
    displayed.
    Windows 95/NT only
    This feature is available on Windows 95/NT only. On
    other platforms, the
    attribute is ignored.
    For the archives, go to:
    http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To
    unsubscribe, send in a new
    email the word: 'Unsubscribe' to:
    forte-users-requestlists.xpedior.com

  • Alv field with f4 help without using class

    Hi,
    Can any one give me a program of "Alv field with f4 help without using class".
    Thanking you in advance.

    hi
    <b>Linking F4 Help to Fields</b>
    For the last section, we will deal with linking F4 help to fields. It is easy. As usual, define, implement and register the event “onf4” at proper places in your code. For F4 help, you must register the fields whose F4 request will trigger the “onf4” event. For this you must prepare a table of type “LVC_T_F4” and register this table using the method “register_f4_for_fields”. While preparing table you must include a line for each field which will trigger F4 event. For each field in the structure;
    &#1048766; Pass the fieldname to ‘FIELDNAME’
    &#1048766; Set ‘REGISTER’ to make the field registered,
    &#1048766; Set ‘GETBEFORE’ to provide field content transport before F4 in editable mode
    &#1048766; Set ‘CHNGEAFTER’ to make the data changed after F4 in editable mode.
    DATA: lt_f4 TYPE lvc_t_f4 WITH HEADER LINE .
    lt_f4-fieldname = 'PRICE'.
    lt_f4-register = 'X' .
    lt_f4-getbefore = 'X' .
    APPEND lt_f4 .
    CALL METHOD gr_alvgrid->register_f4_for_fields
    EXPORTING
    it_f4 = lt_f4[] .
    Preparing table for the fields to be registered to trigger F4 event
    METHOD handle_on_f4 .
    PERFORM f4_help USING e_fieldname es_row_no .
    er_event_data->m_event_handled = 'X' .
    ENDMETHOD .
    A sample “onf4” method implementation
    Again, we set the attribute “er_event_data->m_event_handled” to prevent further processing of standard F4 help.
    regards
    Ravish
    <b>
    reward if useful</b>

  • Help with Merging Two Accounts....

    Hi,
    We ended up with two my Best Buy accounts.
    I called up and talked with someone, who said they would merge the accounts....
    A few hours later, when I logged in, the website said I had two accounts and to choose one to view.
    That lasted for about 4 days,
    Then, the website didn't ask anymore and just logged into one account ... which I thought meant the merge had occured.
    HOWEVER, none of the purchases on the"other" account are on the primary account, which was the point of te

    Hi scXenon,
    I used the email address you registered with the forum to review your information, and I do see that you currently have two active My Best Buy™ accounts.  If the primary information shared between the two accounts matches, then we should have no problem merging them.  That process would involve closing one account, and then moving any unused points/certificates from the closed account to the active primary account.
    I do see that you have an open case with our Account Maintenance department and I trust that they will be able to help successfully merge your accounts; however, I am going to send you a private message to see if there is anything I can help with.  To check your private messages, you would want to login to the forum and click on the yellow envelope icon located at the top of the page.
    Merging My Best Buy™ Accounts
    Thank you for posting!
    Derek|Social Media Specialist | Best Buy® Corporate
     Private Message

  • Getting Help on WMI Classes

    Hi,
    Does PowerShell provide help for WMI classes? I know Get-Help <cmdlet> gives information about the cmdlet. But is there something like, Get-Help <WMI class> which gives the information about the WMI class?
    Ex: Get-Help Win32_Bios
    Thanks!
    NM

    No.  Searcch with your search engine.
    --->> TechNet win32_bios class
    https://www.google.com/#newwindow=1&q=technet+win32_bios+class
    ¯\_(ツ)_/¯

  • My 2008 macbook will not turn on. the light on the corner is on. not flashing but on. its fully charged and has lion on it. please help! my classes start Monday and i need it before then!!

    my 2008 macbook will not turn on. the light on the corner is on. not flashing but on. its fully charged and has lion on it. please help! my classes start Monday and i need it before then!! It will turn on for a coupe seconds, and then turn off.

    Take it into an Apple store for evaluation.

  • Need help in Creating classes for my assignment

    Hi ,
    I just started learning Java and have the following requirement
    1)     Create the following classes/interfaces using descriptions:
    a)     Account � data members : id:String, type:String, balance:BigDecimal, methods : Account, Account with String parameter, getId, getType, getBalance, setId, setType, setBalance, deposit, withdraw, compareTo, toString
    b)     Bank � data members: instance:Bank, accountsMap:Map, customersMap:Map, customersAccount:Map, transactionMap:Map, methods: getAccountsMap, getCustormersMap, getCustomersAccounts, getTransactionMap, associate, addTransaction, getAccount, getCustomer, getAccounts, getTransactions, deposit, withdraw, transfer
    c)     AccountDoesNotExistException, BankException, CustomerDoesNotExistException, InsufficientFundsException, InvalidAmountException, ZeroAmountException
    2)     Create the util package using the following class
    a)     AmountConverter � methods: fromDecimal(BigDecim     al), fromString(String)
    In 1 b how to Create Instance:bank in the class .Also how to do part2.If possible can you help me with all the parts.Based on these I've some more to do.

    Here is what I've come with
    ACCOUNT.JAVA
    import java.math.*;
    public class Account {
    private String Id;
    private String Type;
    private BigDecimal balance;
    public Account( ) {
    public Account(String Id,String Type,BigInteger balance) {
    this.Id = Id;
    this.Type = Type;
    this.balance = balance;
    public String getId( ) {
    return Id;
    public void setId(String Id) {
    this.Id = Id;
    public String getType( ) {
    return Type;
    public void setType(String Title) {
    this.Title = Type;
    public String getBalance( ) {
    return id;
    public void setBalance(String balance) {
    this.balance = balance;
    public String withdraw( ) {
    public String deposit( ) {
    public void setLastName(String LastName) {
    this.id = id;
    CUSTOMER.JAVA
    public class Customer {
    private String Id;
    private String Title;
    private String firstName;
    private String lastName;
    /** Construct a Customer with no data -- must be a no-argument */
    public Customer( ) {
    /** Construct a Customer with String Parameter */
    public Customer(String Id,String Title,String firstName,String lastName) {
    this.Id = Id;
    this.Title = Title;
    this.firstName = firstName;
    this.lastName = lastName;
    /** Return the Id. */
    public String getId( ) {
    return Id;
    /** Set the Id */
    public void setId(String Id) {
    this.Id = Id;
    /** Return the Title */
    public String getTitle( ) {
    return Title;
    /** Set the Title */
    public void setTitle(String Title) {
    this.Title = Title;
    /** Return the Firstname. */
    public String getFirstName( ) {
    return id;
    /** Set the Firstname. */
    public void setFirstName(String FirstName) {
    this.id = id;
    /** Return the Lastname. */
    public String getLastName( ) {
    return LastName;
    /** Set the Lastname. */
    public void setLastName(String LastName) {
    this.id = id;
    TRANSRECORD.JAVA
    import java.util.*;
    import java.math.*;
    public class TransRecord implements Comparable{
    private Date timeStamp;
    private String transType;
    private BigDecimal transAmt;
    /** Construct a Trans Record with no data -- must be a no-argument */
    public TransRecord( ) {
    /** Construct a Customer with String Parameter */
    public Customer(String transType,String transAmt) {
    this.transType = transType;
    this.transAmt = transAmt;
    /** Return the timeStamp. */
    public String gettimeStamp( ) {
    return timeStamp;
    /** Set the timeStamp */
    public void settimeStamp(Date timeStamp) {
    this.timeStamp = timeStamp;
    /** Return the TransType */
    public String getTransType( ) {
    return TransType;
    /** Set the TransType */
    public void setTransType(String TransType) {
    this.TransType = TransType;
    /** Return the TransAmt */
    public String getTransAmt( ) {
    return TransAmt;
    /** Set the TransAmt */
    public void setTransAmt(String TransAmt) {
    this.TransAmt = TransAmt;
    /** Return a String representation. */
    public String toString( ) {
    /** CompareTo method */
    public int compareTo(Object argument)
    ===============
    ACCOUNTDOESNOTEXISTEXCEPTION.JAVA
    public class AccountDoesNotExistException
                   extends Exception
         public AccountDoesNotExistException()
              super();
         public AccountDoesNotExistException(String message)
              super(message);
    =================
    BANKEXCEPTION.JAVA
    public class BankException
                   extends Exception
         public BankException()
              super();
         public BankException(String message)
              super(message);
    CUSTOMERDOESNOTEXISTEXCEPTION.JAVA
    public class CustomerDoesNotExistException
                   extends Exception
         public CustomerDoesNotExistException()
              super();
         public CustomerDoesNotExistException(String message)
              super(message);
    ACCOUNTDOESNOTEXISTEXCEPTION.JAVA
    public class AccountDoesNotExistException
                   extends Exception
         public AccountDoesNotExistException()
              super();
         public AccountDoesNotExistException(String message)
              super(message);
    INSUFFICIENTFUNDSEXCEPTION.JAVA
    public class InsufficientFundsException
                   extends Exception
         public InsufficientFundsException()
              super();
         public InsufficientFundsException(String message)
              super(message);
    INVALIDAMOUNTEXCEPTION.JAVA
    public class InvalidAmountException
                   extends Exception
         public InvalidAmountException()
              super();
         public InvalidAmountException(String message)
              super(message);
    ZEROAMOUNTEXCEPTION.JAVA
    public class ZeroAmountException
                   extends Exception
         public ZeroAmountException()
              super();
         public ZeroAmountException(String message)
              super(message);
    I need help with Bank Class and the util class.Correct me If I've missed any exceptions or if any syntax is wrong
    THanks
    AKsh

  • Student in need of help (Trouble merging cells in CS3)

    I am currently attending college, pursuing a degree in computer systems. One of the required courses is web design. I am using Adobe Dreamweaver CS3, and lets just say, I don't particularly like it.
    Our instructor wants us to familiarize ourselves with Dreamweaver by building a basic page using tables.
    His required outline is this : http://img231.imageshack.us/img231/3855/pagedesign.png
    Now, to start, I have no problem creating the table. That is easy. The problem I have is shaping everything to look like that picture. I've been trying to do this with a 7 x 10 table.
    My technique so far has been to merge all of the cells on the top row for text1, then I Merge all of the cells for the borders on the far left and the far right. After that, I merge the cells necessart for text2. Again, no problems so far. After I have merged the cells for text2, I create the border directly to the left of Page Name and Graphic1 by merging the cells, then I merge the cells for Page Name. Once again, no problems so far. After that, I merge the cells for graphic1, and then create seperator between graphic1,  and graphic2. Once I have done that, I merge the cells for Text3.
    Now, here is where I run into problems. When I merge the cells for graphic2, I hope to get the result that is in that image, however, instead of getting that result, the cell shrinks. Some things I have already tried to remedy this problem (keep in mind, I am completely new to this, so in all reality, I have no clue what I'm doing):
    1. I tried deleting the table, redoing it, but starting from the bottom, going up. With this strategy, instead of graphic2 giving me a problem, the seperator between graphic1 and graphic2 shrunk in height but expanded in width.
    2. I tried simply resizing the cell through the properties manager. This did not work at all. When I entered the value, value vanished.
    3. I tried messing around with the resizing tool, but that did no good as it cannot change just one cell. It changes all the cells on the table.
    4. I tried inserting new rows/columns and remerging the cells according to the new rows/columns I entered. This did not work at all.
    So, that is my problem. I wish I could give a graphical image of the problem (Like a before and after picture) but unfortunatley I am not in class right now and that is the only place I have access to dreamweaver. I have asked my instructor about this problem and he told me to try and insert text or an image into the cell so it would not resize. He has made it clear that he cannot step by step instructions because we have to figure it out on our own. I can understand where is coming from but in the same respect, I don't feel as if I am gaining any kind of knowledge as to how to use dreamweaver.
    Whoever could help me with this problem: It would be greatly appreciated. I hate falling behind in class and that is why I feel is happening right now because I cannot get past this part. Another student attempted to help me but he couldn't figure it out either, even after he reconstructed the page himself on another computer without any problem.
    Thank you again for whoever helps. If you have any questions about my problem, feel free to post it here. Thanks again

    I was bored and feeling generous...lol I thin this code will create the table layout your looking for. I will express my distain for tables used for page layouts, as they are not standard anymore. But you do have to follow your instructors lead. Anyway, here is the code.
    function(){return A.apply(null,[this].concat($A(arguments)))}
    <table border="1" cellspacing="2" cellpadding="2">
      <tr>
        <td colspan="6">text1</td>
      </tr>
      <tr>
        <td width="2" rowspan="7"> </td>
        <td colspan="4">text2</td>
        <td width="18" rowspan="7"> </td>
      </tr>
      <tr>
        <td width="14" rowspan="3"> </td>
        <td colspan="3">page name</td>
      </tr>
      <tr>
        <td width="68" rowspan="2">graphic1</td>
        <td width="6" rowspan="3"> </td>
        <td height="57">text3</td>
      </tr>
      <tr>
        <td width="64" rowspan="2">graphic2</td>
      </tr>
      <tr>
        <td colspan="2">blank space</td>
      </tr>
      <tr>
        <td colspan="4">text4</td>
      </tr>
      <tr>
        <td colspan="4">text5</td>
      </tr>
    </table>
    Hope that works for you. hmmm this forum is so buggy. I inserted raw code...maybe the wrong thing to do. Trying again.
    Message was edited by: teedoffnewbie wasnt exactly right.

  • Please help me merge two images

    I've been reading tutorials for hours, and trying everything I can think of, but I just can't figure this out.
    I have two BufferedImages (TYPE_INT_RGB), and I want to be able to create an alpha channel "mask" that lets me punch "holes" (antialiased) in the top one to have the bottom one show through. I can draw white circles (Ellipse2D.Double) to my heart's content on the top or bottom image, but I can't figure out how to use this as a alpha channel mask or how to use AlphaComposite to put it all together. Can someone please offer help?

    I merged the top 2 responses together to get an antialiased version. Then I saw the post below. Can anyone comment on which version is more efficient? Thanks for all your help.
    import java.awt.AlphaComposite;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.GraphicsConfiguration;
    import java.awt.GraphicsDevice;
    import java.awt.GraphicsEnvironment;
    import java.awt.Rectangle;
    import java.awt.RenderingHints;
    import java.awt.Transparency;
    import java.awt.geom.Area;
    import java.awt.geom.Ellipse2D;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    public class ImageHoles extends JPanel {
        BufferedImage[] images;
        Area mask;
        ImageHoles(BufferedImage[] images) {
            this.images = images;
            // Set the mask = null and call repaint
            // inside componentResized method of a
            // ComponentListener added to this.
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            int w = getWidth();
            int h = getHeight();
            int x = (w - images[0].getWidth())/2;
            int y = (h - images[0].getHeight())/2;
            // draw bottom image
            g.drawImage(images[0], x, y, this);
            x = (w - images[1].getWidth())/2;
            y = (h - images[1].getHeight())/2;
            if(mask == null) {
                createMask(x, y);
            // from Chris Campbell's Blog (see above)
    //      Create a translucent intermediate image in which we can perform
    //      the soft clipping
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice gs = ge.getDefaultScreenDevice();
            GraphicsConfiguration gc = gs.getDefaultConfiguration();
            BufferedImage img = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT);
            Graphics2D g2 = img.createGraphics();
    //      Clear the image so all pixels have zero alpha
            g2.setComposite(AlphaComposite.Clear);
            g2.fillRect(0, 0, w, h);
            g2.setComposite(AlphaComposite.Src);
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setClip(mask);
            g2.setColor(Color.WHITE);
            g2.fill(mask);
            BufferedImage hi = images[1];
            g2.setComposite(AlphaComposite.SrcAtop);
            g2.drawImage(hi, 0,0,hi.getWidth(), hi.getHeight(), this);
            g2.dispose();
            // from Chris Campbell's Blog (see above)
            // draw masked antialias layer
            g.drawImage(img, x, y, this);
        private void createMask(int x, int y) {
            int w = images[1].getWidth();
            int h = images[1].getHeight();
            Rectangle r = new Rectangle(x, y, w, h);
            Ellipse2D e1 = new Ellipse2D.Double(x+20, y+75, 25, 25);
            int cx = x + w/2;
            int cy = y + h/2;
            Ellipse2D e2 = new Ellipse2D.Double(cx-30, cy-30, 60, 60);
            Ellipse2D e3 = new Ellipse2D.Double(x+w-60, y+h-60, 40, 40);
            mask = new Area(r);
            mask.subtract(new Area(e1));
            mask.subtract(new Area(e2));
            mask.subtract(new Area(e3));
        public static void main(String[] args) throws IOException {
            String[] ids = { "polarBear", "hawk" };
            BufferedImage[] images = new BufferedImage[ids.length];
            for(int j = 0; j < images.length; j++) {
                String path = "images/" + ids[j] + ".jpg";
                images[j] = ImageIO.read(new File(path));
            ImageHoles test = new ImageHoles(images);
            test.setPreferredSize(new Dimension(images[0].getWidth(),images[0].getHeight()));
            JOptionPane.showMessageDialog(null, test, "", -1);
    }

  • Help using scanner class to count chars in file

    Hi all, I am learning Java right now and ran into a problem. I need to use the Scanner class to accurately count the number of chars in a file including the line feed chars 10&13.
    This what I have and it currently reports a 201 byte file as having 194 chars:
         File file = new File(plainFile);
         Scanner inputFile = new Scanner(file);
         numberOfChars = 0;
         String line;
         //count characters in file
         while (inputFile.hasNextLine())
              line = inputFile.nextLine();
              numberOfChars += line.length();
    I know there are other ways using BufferedReader, etc but I have to use Scanner class to do this.
    Thanks in advance!

    raichle wrote:
    Wow guys, thanks for the help! I've got a RTFMWell, what's wrong to have a look at the API docs for the Scanner class?
    and directions that go against the specs I said.Is that so strange to suggest a better option? What if I ask a carpenter "how do I build a table with a my stapler?". Should I give the man an attitude if he tells me I'd better use a saw and hammer?
    I'm also aware that it "eats" those chars and obviously looking for a way around that.
    I've looked through the java docs, but as I said, I'm new to this and they're difficult to understand. The class I am auditing req's that this be done using Scanner, but I don't see why you demand an explanation.
    Can anybody give me some constructive help?Get lost?

  • [Help] Using a class at the other class

    hi guys, i'm still new to java. So that i tried to learn by myself.
    i got 2 class: 'Person.java' and 'Ex1.java'
    basically, Person just a class for making an object of Person. and the main function is made at Ex1.java.
    my problem is: i made 2 Person objects (p1 and p2). then i tried to initialise them in 2 ways (using default constructor and user-defined constructor). Why when i print 'em (p1.print() and p2.print()), it printed p1 attributes only. I tried many ways to do this, but can't find the way out. pls help me...
    * Person.java *
    public class Person {
         // attributes
         private static String name;
         private static int age;
         // constructor
         public Person() {
              name = "";
              age = -1;
         public Person(String n, int a) {
              name = n;
              age = a;
         // mutator
         public static void setName( String n ) { name = n; }
         public static void setAge( int a) { age = a; }
         // other methods
         public static void print() {
              System.out.println( name + " (" + age + " years old)" );
    * Ex1.java *
    public class Ex1{
         private static Person p1;
         private static Person p2;
         public static void main(String args[]) {
              p1 = new Person();
              p2 = new Person("Jessica", 25);
              p1.setName("Antonio");
              p1.setAge(20);
              p1.print();
              p2.print();
    }

    Change
    public class Person {
         // attributes
         private static String name;
         private static int age;
    to
    public class Person {
         // attributes
         private String name;
         private int age;
    You're using incorrectly static for object attributes:)

  • Need help with merging itunes accounts.

    Hello.  I was wondering if any of you mac experts can help me.  My husband and I recently purchased a new mac and are having trouble figuring out how to merge our information into our computer's itunes.  I set up the computer under my apple ID/email.  However we both have separate apple id's linked with the same bank account information.  The problem is, itunes on our computer isn't recognizing any of the purchases through my husband's apple id, even though they were paid for through the same account.  I haven't been able to figure out whether or not I can add his apple id/email to itunes and merge the two, since a substantial amount of music/apps/etc were purchased under his ID.  Surely it's possible to have more than on apple id on one family's computer?  Anyone know?  Hopefully I worded this clearly enough.  Thanks!

    Open the NetInfo Manager in the /Applications/Utilities/ folder, click the padlock, type in your password, and then locate that account in the list of users. Delete that account and only that account; don't make any other changes. The account's home folder will remain on the drive.
    (11474)

  • Could someone help me with class Process getErrorStream() ??

    Hello
    I want to execute process "/usr/bin/octave" .So I have to write to its input and read its output and error stream. I have written program and it works good until I need to read error stream of process. After I read the error stream of process i receive the IOException Broken pipe. It looks like after read the data from error stream process is closed so I coudn't write anything to the input stream (what i could do before reading from error stream). The errors I receive :
    java.io.IOException: Broken pipe
    at java.io.FileOutputStream.writeBytes(Native Method)
    at java.io.FileOutputStream.write(Unknown Source)
    at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
    at java.io.BufferedOutputStream.flush(Unknown Source)
    at sun.nio.cs.StreamEncoder$CharsetSE.implFlush(Unknown Source)
    at sun.nio.cs.StreamEncoder.flush(Unknown Source)
    at java.io.OutputStreamWriter.flush(Unknown Source)
    at java.io.BufferedWriter.flush(Unknown Source)
    at wazna$3.run(octave.java:116)
    at java.lang.Thread.run(Unknown Source)
    And here is my code:
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    public class octave{
    public static void main(String[] args) throws IOException, InterruptedException {
    Runtime r = Runtime.getRuntime();
    final Process p= r.exec("/usr/bin/octave");
    System.out.print(">>");
    InputStream iss = p.getInputStream();
    BufferedReader br =
    new BufferedReader(new InputStreamReader(iss));
    try {
    while (iss.available() == 0) { }
    while (br.ready())
    System.out.println(br.readLine());
    } catch (IOException e) { e.printStackTrace();}
    String s=null;
    do
    System.out.print(">>");
    BufferedReader in = new BufferedReader(new
    InputStreamReader(System.in));
    s = in.readLine();
    if (s.equalsIgnoreCase("exit"))
    System.out.print(">>");
    System.out.print("END");
    else
    Thread reading = new Thread(
    new Runnable()
    synchronized public void run()
    InputStream iss = p.getInputStream();
    BufferedReader br =
    new BufferedReader(new InputStreamReader(iss));
    try {
    while (iss.available() == 0) { }
    while (br.ready()) {
    System.out.println(br.readLine());
    } catch (Exception e) {e.printStackTrace();                                                                                                                                } }
    Thread error = new Thread(
    new Runnable()
    synchronized public void run()
    InputStream err=p.getErrorStream();
    BufferedReader er =
    new BufferedReader(new InputStreamReader(err));
    try {
    while (err.available() == 0) {
    while (er.ready()) {
    System.err.println(er.readLine());
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    final String g=s;
    Thread writing = new Thread(
    new Runnable()
    synchronized public void run()
    OutputStream oos = p.getOutputStream();
    BufferedWriter bw =
    new BufferedWriter(new OutputStreamWriter(oos));
    try {
    bw.flush();
    bw.write(g);
    bw.newLine();
    bw.flush(); //LINE 116 where is an error
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    writing.start();
    reading.start();
    error.start();
    while (!s.equalsIgnoreCase("exit"));
    Message was edited by:
    tazja
    Message was edited by:
    tazja

    I know it's a bit late for this. But I hope it will help all the people who encountered this problem.
    The only way to let octave work with streams is to use the --interactive switch (otherwise it will crash on the first error). Rembember that using this will need a different way to read data (BufferedReader won't work well).
    Hope this helps anyone, I spent very much time figuring this.
    Bye

  • Need help in merging two database

    Dear All,
    Can any one please let me know the methodology/Best practices for merging two databases.
    We are having two oracle Database A and B, the data from
    Database A has to be migrated to Database B using PL/SQL scripting.
    it will be a great help,Thanks in advance!

    Hi,
    Use the DB Links and try to use the "MERGE" that is better.
    you can clone it right, almost you are getting the same data from A to B and then you are going to Update is I am correct. Does the "B" consist the data, If yes then you can't clone on exiting DB, As i said above go for DB links and write custom scripts as per your requirement.
    Refer for DB links
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/ds_admin.htm#sthref4108
    - Pavan Kumar N

  • Can someone help with Merging Files

    Why can't I merge folders ike it says in Help under Folder Basics.
    "Merge two folders
    If you have two folders with identical names at two different locations, you can merge them into a single folder. To do so, you must copy (not move) one folder to the location that already contains a folder with the same name. In the dialog that appears, click Merge.
    The Merge option appears only if one of the folders contains items that are not in the other folder. If the folders contain different versions of identically named files, the only options are Stop or Replace."
    yes they are named identically.
    yes they contain some files that are the same and some that are not the same.
    yes some of the same files in each folder are the same versions and some are not the same versions
    Running osx 10.9.2.
    Does having the location on two different Hard Drives make any difference? The help does not mention that being a problem.

    I suspect you may need to do the usual 'keyboard mashing' to make OS X copy (not move) the folders in question.
    Try the usual modifiers, command, alt, ctrl (and combinations of them) as you drag until you get the indication a move will happen. I think alt will do it (that shows a green icon on the dragged file/folder).
    Does this help make it any clearer…
    http://www.switchingtomac.com/tutorials/osx/understanding-replace-replace-merge- os-x-mavericks/
    P.S. copy is the default behavior across different volumes.

Maybe you are looking for

  • How to compare 2 dates in a JPA QL query

    hello all, how can i compare 2 dates in JPA QL ,? my idea was to convert the dates to String, and i used 'to_char', but i think it doesn't work in JPA QL; this is my query(it works in oracle but not in java) : Query q=em.createQuery("select sum(o.mon

  • Unable to create IDocs

    I have downloaded Idoc(Already existing in the system with status 53) data using FM IDOC_READ_COMPLETELY(by passing an Idoc number) and passing this downloaded data to FM MASTER_IDOC_DISTRIBUTE to create new Idoc with same data. Idoc does gets create

  • Errors generating reoprs using jasperReports in dwr

    I am generating reports using jasperReports in dwr .i am getting these errors Errors were encountered when compiling report expressions class file: D:\Program Files\Apache Software Foundation\Tomcat 5.0\item_1195287830437_658743.java:4: package net.s

  • Can anyone recommend an app similar to idvd?

    I don't know why Apple got rid of iDVD but can anyone recommend an app for burning an iMovie project to DVD?

  • Please help on SA38

    Hello, I tried searching on this forum, but could not find an answer to my question.  I am an auditor and I have been assigned the following access at my company: T-Code: SA38 S_PROGRAM: SUBMIT Authorization: * Based on my limited understanding, this