Placeholder

CSIS 312 Assignment 7 Pair Class

$19.00

Description

Write a generic class Pair which has two type parameters—F and S—each representing the type of the first and second element of the pair, respectively. Add set and get methods for the first and second elements of the pair and be sure to demonstrate your setters/getters actually work. (Hint: The class header should be public class Pair and the best way to demonstrate your setters is to call them from your constructor(s).)
Write a separate PairTest class to test class Pair. Create 2 Pair types and test your get and set methods on the following pair types:
Pair p1 takes Integer and String types as a pair
Pair p2 takes String and Integer
PairTest should output enough information to the terminal to show that your generic class Pair is able to set() and get() different types
SCREENSHOTS
SOLUTION
PAYMENT
CSIS 312 – ADVANCED OBJECT-ORIENTED PROGRAMMING Assignment 7
CSIS 312 – ADVANCED OBJECT-ORIENTED PROGRAMMING Assignment 7
The solution consists of:
A report word document for this assignment
All Java programs and classes
A Netbeans project in case you want to run the project on your computer.
Screenshots showing program running
Attachments [Move over files to preview content of those files]
CSIS_312_Assignment_7.zip (194.80 KB)
classes
Pair.class
PairTest.class
CSIS312 Assignment 7Report.docx
Netbeans project
CSIS312Assignment7
pom.xml
src
main
java
Pair.java
PairTest.java
target
classes
.netbeans_automatic_build
Pair.class
PairTest.class
generated-sources
annotations
maven-status
maven-compiler-plugin
compile
default-compile
createdFiles.lst
inputFiles.lst
test-classes
.netbeans_automatic_build
screenshots
CSIS 312 Assignment 7 Screenshot 1.jpg
CSIS 312 Assignment 7 Screenshot 2.jpg
source code
Pair.java
PairTest.java
Preview Pair.java
xxxxxx xxxxx xxxx
{
xxxxxxx x xxxxx;
private S second;

public Pair() {

}

public F getFirst() {
xxxxxx xxxxx;
}
xxxxxx xxxx xxxxxxxx(x xxxxx) {
xxxx.xxxxx = xxxxx;
}
Preview PairTest.java
xxxxxx xxxxx xxxxxxxx {
xxxxxx xxxxxx xxxx xxxx(xxxxxx[] xxxx) {
xxxx
x1 = xxx xxxx
(); // xxxx x1 xxxxx xxxxxxx xxx xxxxxx xxxxx xx x xxxx
System.out.println(“Create an object p1 takes Integer and String types as a pair”);
System.out.println(“Test set method”);
p1.setFirst(1);
p1.setSecond(“String”);
System.out.println(“Test get method”);
if (p1.getFirst() != 1 || !p1.getSecond().equals(“String”)) {
System.out.println(“ERROR”);
} xxxx {
xxxxxx.xxx.xxxxxxx(“xxxxx: ” + x1.xxxxxxxx());
xxxxxx.xxx.xxxxxxx(“xxxxxx: ” + x1.xxxxxxxxx());
}
xxxxxx.xxx.xxxxxxx();
Preview Pair.java
xxxxxx xxxxx xxxx
{
xxxxxxx x xxxxx;
private S second;

public Pair() {

}

public F getFirst() {
xxxxxx xxxxx;
}
xxxxxx xxxx xxxxxxxx(x xxxxx) {
xxxx.xxxxx = xxxxx;
}
Preview PairTest.java
xxxxxx xxxxx xxxxxxxx {
xxxxxx xxxxxx xxxx xxxx(xxxxxx[] xxxx) {
xxxx
x1 = xxx xxxx
(); // xxxx x1 xxxxx xxxxxxx xxx xxxxxx xxxxx xx x xxxx
System.out.println(“Create an object p1 takes Integer and String types as a pair”);
System.out.println(“Test set method”);
p1.setFirst(1);
p1.setSecond(“String”);
System.out.println(“Test get method”);
if (p1.getFirst() != 1 || !p1.getSecond().equals(“String”)) {
System.out.println(“ERROR”);
} xxxx {
xxxxxx.xxx.xxxxxxx(“xxxxx: ” + x1.xxxxxxxx());
xxxxxx.xxx.xxxxxxx(“xxxxxx: ” + x1.xxxxxxxxx());
}
xxxxxx.xxx.xxxxxxx();
Price: $19
You May Also Like:
CSIS 312 Entire Course
CSIS 312 Assignment 1 Time2 Class
CSIS 312 Assignment 2 Employee Class
CSIS 312 Assignment 3 Payroll System
CSIS 312 Assignment 4 Random Sentences
CSIS 312 Assignment 5 LinkedList Object
CSIS 312 Assignment 6 printArray and Factorial Calculator
CSIS 312 Assignment 8 Stack Data Structure

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.