Program for write a class with the header, JAVA Programming

PART1:

Write a class with the header

public class OrderedPair>

implements Comparable>

instance variables

private Key x

private Key y

constructor

publicOrderedPair(Key x, Key y) // initialize the instance variables

methods

(i) accessor and mutator methods for the instance variables.

(ii) publicintcompareTo(OrderedPair s)

if (this.x  is not equal to s.x) then return x.compareTo(s.x)

else return y.compareTo(s.y)

(iii)  public String toString() - returns a String that represents x and y as an ordered pair.  For instance, if x = "cat " and y = "dog ", then this method returns  the String, "(cat , dog ) ". 

PART2

A class with the header

public class OrderedPairException extends Exception

This class has a constructor with the following header

publicOrderedPairException(String msg)

The only statement in this constructor uses the parameter, msg, to invoke the constructor in the Exception class.

PART3:

Add the following methods to the SET class

public SET difference(SETst)

Returns the complement of this set with the set object represented by the parameter, st.  (In order words, return this - st)

public void display()

Displays the contents of this set.    Use the toString method to display each element in the set.  If the set is null or it's empty then display "Empty Set".

public SetorderedPairs(SETst) throws OrderedPairedException

Returns a set consisting of the ordered pairs in this set and the set represented by the parameter, st.

If this set is null or it's empty then throw an OrderedPairException that contains the message "First Coordinate Set is Null".

If the set represented by the parameter st is null or it's empty then throw an OrderedPairException that contains the message "Second Coordinate Set is Null".

Example  if c = {"A", "B", and "C"} and d = {"X", "Y"}  then the set of order pairs is

{ ("A", "X"), ("A", "Y"), ("B", "X"), ("B", "Y"), ("C", "X"), ("C", "Y") }

Posted Date: 3/25/2013 5:42:58 AM | Location : United States







Related Discussions:- Program for write a class with the header, Assignment Help, Ask Question on Program for write a class with the header, Get Answer, Expert's Help, Program for write a class with the header Discussions

Write discussion on Program for write a class with the header
Your posts are moderated
Related Questions
Ask question Write an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square. Use Quadrilateral as the superclass of the hierarchy. Create

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4

Why do we call JavaScript an Object-based Language? In java language an JavaScript shares several similarities with object-oriented languages, and thus is known as an object-ba

Explain BIOS in java language? BIOS basically stand for Basic input/output system it is also called as the system BIOS or ROM BIOS is a de facto standard describing a firmware

Which models are supported by JMS? Please, explain them. Ans) Publish or subscribe (pub/sub). This model permits a client (publisher) to send messages to a JMS topic. These mess

Prepare a Program that can solve OCR Captcha Project Description: I'm seeking someone to develop a program that can solve a php captcha. It should be a web service or scri

how do you write the code so the line will be clipped

EJB 2.x is broadly adopted server side component architecture for J2EE. 1. EJB is a remote, distributed multi-tier system and allows protocols like IIOP, JRMP, and HTTP etc.

Write a Java REST client to perform the following- The client will read the contents of the file - invoice.txt. The first line of the file will display the type of the currency.

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4