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
You are to write a Java console application, following the Software Life Cycle model, which will read personnel records from a text file and store them in a data structure.  One li

It helps to resolve naming conflicts when different packages have classes with the same names. This also helps you prepare files within your project. As define : java.io package


1. Which of the following are not valid Java identifiers, and why? (a) wolVes (b) United(there is only one) (c) 87 (d) 5 3 (e) Real ale (f) isFound?by 2. A cla

object

write complete application to play game tictactoe

Write down HTML or JavaScript code for the following requirements: Declare an Array along with the identifier SUBJECT having length 5. Assign subsequent values to the array par

O/R mapping is well suited for read, change, write centric applications and not suited for write centric applications where data is seldom read. Although this was usually true of m

What Is a Socket in Java Networking and RMI? Ans) A socket is one end-point of a two-way communication link among two programs running on the network. A socket is bound to a por

Want an expert with knowledge of UML diagrams and writing experience for pages writing including diagrams. This project needs 3-4 pages of technical writing about tickets reserv