Entries by Student

write my assignment 31151

ColorPoint Class and InvalidRgbException a class named Colorpoint with the following fields, I attached the requirement, here is what I have, just want make sure is there any part that I miss, like the last requirement (In main() n array of ColorPoint objects of size 10. Populate the array with objects that have random values for colors -use random number generator to set RGB fields, and (x, y) set to (0, 0)…(9,9). Pass that array to the method writeColorPointArray()to be stored in a file “colorPoints.dat”.Then use readColorPointArray()method to read the stored data from file and display it into the screen.)

Program Code :-

import java.io.EOFException;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.ObjectInputStream;

import java.io.ObjectOutputStream;

import java.util.ArrayList;

import java.util.Collections;

import java.util.Objects;

public class ColorPointDemo {

  public static void main(String[] args) {

    try {

      ArrayList<Colorpoint> cps = new ArrayList<>();

      Colorpoint obj1 = new Colorpoint(100,100,20,20,20);

      cps.add(obj1);

      Colorpoint obj2 = new Colorpoint(0,0,10,10,10);

      cps.add(obj2);

      obj1.equals(obj2);

      System.out.println(“obj1:” + obj1.toString());

      // call the wrtiters.

      Colorpoint[] countries = cps.toArray(new Colorpoint[cps.size()]);

      writeColorPointArray(“colorPointsFile.dat”, countries);

      System.out.println(“Finished saving objects into a binary file!”);

      Colorpoint[] readFromFile = readColorPointArray(“colorPointsFile.dat”);

      System.out.println(“Finished reading Objects from binary file…”);

      for (Colorpoint c : readFromFile) {

        System.out.printf(“>> %sn”, c.toString());

      }

    } catch (Exception e) {

//      e.printStackTrace();

      System.err.println(“ERROR: ” + e.getMessage());

    }

  }

  public static Colorpoint[] readColorPointArray(String fileName)

      throws IOException {

    ArrayList<Colorpoint> colorPoints = new ArrayList<>();

    try {

      File file = new File(fileName);

      // open the binary file

      if (file.exists()) {

        ObjectInputStream inputStream

            = new ObjectInputStream(new FileInputStream(file));

        Colorpoint cp = null;

        try {

          while (true) {

            cp = (Colorpoint) inputStream.readObject();

            colorPoints.add(cp);

            System.out.printf(“reading ColorPoints:%sn”,cp.toString());

          }

        } catch (EOFException e) {

          System.out.println(“No more numbers in the file.”);

        }

        inputStream.close();

      }

    } catch (FileNotFoundException e) {

      System.out.println(“Cannot find file numbers.dat.”);

    } catch (IOException e) {

      System.out.println(“Problem with input from file numbers.dat.”);

    } catch (ClassNotFoundException e) {

      e.printStackTrace();

    }

    //return (Colorpoint[]) colorPoints.toArray();

    return colorPoints.toArray(new Colorpoint[colorPoints.size()]);

  }

  public static void writeColorPointArray(String fileName, Colorpoint[] points)

      throws IOException {

    ObjectOutputStream outputStream = null;

    try {

      File file = new File(fileName);

      // open the binary file

      if (file.exists()) {

        file.delete();

      }

      if (file.createNewFile()) {

        System.out.println(“created a new file!”);

      } else {

        System.out.println(“failed to create a new file!”);

      }

      outputStream

          = new ObjectOutputStream(new FileOutputStream(file));

      for (Colorpoint cp : points) {

        if (Objects.nonNull(cp)) {

          outputStream.writeObject(cp);

          System.out.printf(“object is non null and added! cp: %sn”, cp);

        }

      }

    } catch (FileNotFoundException e) {

      System.out.println(“Cannot find file.”);

    } catch (IOException e) {

      System.out.println(“Problem with input from file.”);

    }

    if (outputStream != null) {

      outputStream.close();

    }

  }

}

<<<<<————————————————————————————————————————->>>>>

import java.io.Serializable;

public class Colorpoint implements Serializable {

  private int x; //x coordinate on a plane

  private int y; //y coordinate on a plane

  private int colorR; //red color component

  private int colorB; //blue color component

  private int colorG; //green color component

  public Colorpoint() {

    x = 0;

    y = 0;

    colorR = 0;

    colorB = 0;

    colorG = 0;

  }

  public Colorpoint(int cordX, int cordY, int colR, int colG, int colB) {

    x = cordX;

    y = cordY;

    colorR = colR;

    colorB = colB;

    colorG = colG;

  }

  public void setXY(int x, int y) {

    this.x = x;

    this.y = y;

  }

  /**

   * @return the x

   */

  public int getX() {

    return x;

  }

  /**

   * @return the y

   */

  public int getY() {

    return y;

  }

  public void setRGB(int colorR, int colorG, int colorB) throws InvalidRgbException {

    // specify the cause of the error in message by throwing Exception

    if (colorR < 0 || colorR > 255) {

      throw new InvalidRgbException(“Invalid entry of R value . 0 To 255” + colorR);

    } else if (colorG < 0 || colorG > 255) {

      throw new InvalidRgbException(“Ivalid entry of G number . 0 To 255” + colorG);

    } else if (colorB < 0 || colorB > 255) {

      throw new InvalidRgbException(“Ivalid entry of B number . 0 To 255” + colorB);

    } else {

      this.colorR = colorR;

      this.colorG = colorG;

      this.colorB = colorB;

    }

  }

  /**

   * @return the colorR

   */

  public int getColorR() {

    return colorR;

  }

  /**

   * @return the colorB

   */

  public int getColorB() {

    return colorB;

  }

  /**

   * @return the colorG

   */

  public int getColorG() {

    return colorG;

  }

  @Override

  public String toString() {

    return “The cordination of X is: ” + x + ” and the cordination of Y is: ” + y;

  }

  @Override

  public boolean equals(Object o) {

    if (o instanceof Colorpoint) {

      Colorpoint cp = (Colorpoint) o;

      if (this.x == cp.x && this.y == cp.y

          && this.colorB == cp.colorB

          && this.colorG == cp.colorG

          && this.colorR == cp.colorR) {

        return true;

      }

    }

    return false;

//return super.equals(o);

  }

}

<<<<———————————————————————————————–>>>>

public class InvalidRgbException extends Exception{

  //Parameterized construction

  public InvalidRgbException(String message){

    super(message);

  }

}

:

  • Attachment 1
  • Attachment 2
  • Attachment 3

Color Point Class and Binary File 110Continue working with the same project . In the file next to mail ; create two new*methods .public Static ColorPoint [ !`LEGOCOL OF F O int Array / String FILENAME]andpublic Static Void Uri _ _ _ _ _ _ _ F O int Array ( String FILENAME .COLOREDINt !’ PointE !`Both methods must throw I’DExceptions . The [ OExceptions may originate in the*methods but must not be handled. All Exceptions must be propagated to the calling code.Please handle Class Not Found Exception in the readcolor FaintArray ! ! methodLE GUE OL OF E C int Array ! ! method reads the contents of a binary file and places it intoan array of objects of type Color Point . Assume You do not know the amount of data inthe file . When reading the file store the objects in Array L ist first . After the End of file hasbeen reached . convert the Array List into a regular array and return it from method . Please*study EOF Demo_ java code example ( can be found next to this assignment ; to learn howto USE Exceptions When checking for the End of file while reading from binary file .HE I _ _ _ _ _ _ _ F O intArray ! ! method writes the contents of the given array into the FIVETIbinary file .In mainly create an array of Color Point objects of size 10 . Populate the array with objects thathave random values for colors – use random number generator to get RGE fields , and is . I j set to10.09) … 1 9. 9 ).Pass that array to the method writ E Color Faint Array ! ! to be stored in a file* color Points . dat* . Then use read_ _ _ _ _ Faint Array ! ! method to read the stored datafrom file and display it into the screen .

 

"Not answered?"


Get the Answer

write my assignment 26861

.

Royally appointed first as command of English forces in New York, the expelling of the Massachusetts governor in 1774 would cause his reappointment from military service to political leadership.

B.

Leader of the aggressive campaign to remove the royally appointed stamp distributer Andrew Oliver from Boston in the wake of the first round of taxes post Seven Years’ War.

C.

Boston silversmith who’s engraving of the Boston Massacre would become one of the most noteworthy examples of propaganda in American history.

D.

Successful Philadelphia Lawyer who’s most famous contribution to the patriot cause was a theoretical editorial written about a farmer comparing the Townshend duties to forms of slavery because of his hardships and lack of representation.

E.

British Prime Minister during the 1770s, he was responsible for the repeal of most of the Townshend duties, but still deemed untrustworthy, and was accused of trying to squander more colonial funds into the British coffers by removing the competing Dutch tea trade.

F.

As Prime Minister of England during much of the period of revolutionary fervor in the colonies, he was directly responsible for some of the more controversial decisions during the pre-war period, including the appointment of Townshend as minister of finance.

G.

Royal Governor of Virginia who, in 1775, proclaimed freedom to any slaves who willingly enlisted to serve the king’s army.

H.

Governor of Virginia with personal financial interests in the expansion of territory who commissioned a young George Washington to his first assignment, which would also be a catalyst for the Seven Years’ War.

I.

As an Anglican minister, this religious leader’s message would curry favor with many who had belonged to the Church of England including noted reformers and politicians of the time.

J.

His diary, written using literary skills that were illegal for him to have learned, is one of today’s greatest resources into the harsh realities of the 18th century life for slaves.

K.

English Prime Minister during the early stages of rebellion in the colonies; he is directly tied to the ill-received Sugar and Stamp Acts which he claimed were measures to recoup financial losses by the crown during the Seven Years’ War.

L.

Elderly leader of the Mohawk tribe whose distrust in the British caused a limited alliance between the colonizers and former Native American allies prior to the Seven Years’ War.

 

"Not answered?"


Get the Answer

write my assignment 9349

Discussion 1: Evidence Base in Design

When politics and medical science intersect, there can be much debate. Sometimes anecdotes or hearsay are misused as evidence to support a particular point. Despite these and other challenges, however, evidence-based approaches are increasingly used to inform health policy decision-making regarding causes of disease, intervention strategies, and issues impacting society. One example is the introduction of childhood vaccinations and the use of evidence-based arguments surrounding their safety.

In this Discussion, you will identify a recently proposed health policy and share your analysis of the evidence in support of this policy.

To Prepare:

  • Review the Congress website provided in the Resources and identify one recent (within the past 5 years) proposed health policy. (https:// )
  • Review the health policy you identified and reflect on the background and development of this health policy.

 

"Not answered?"


Get the Answer

write my assignment 877

Here are the facts for your client letter project:Ima Kollector, an unmarried Washington state resident, purchased a painting for $500,000 on February 14, 2013. There was no signature on the painting, and the art dealer did not make any representations regarding who had painted it or what it was valued at. On December 15, 2013, Ima had the painting appraised by three appraisal companies, and each company told her that the painting was worth at the most $500. Ima would like for you to research whether she may deduct this loss on her 2013 federal income tax return.Please cite the code and other tax materials when asnwering the question.

 

"Not answered?"


Get the Answer