Java code: You will need to create a consumer priority queue class that will pro
ID: 3767522 • Letter: J
Question
Java code:
You will need to create a consumer priority queue class that will process the calls. You will need to create a random generator to determine if the call was successful or not. The producer will output to a status report file reporting the success or failure of each call.
If the record was flagged as invalid or DND by the producer process, then you will not attempt to dial this number but instead simple output it to the status report file as invalid or DND.
Store the numbers that have already been dialed in a data structure to guaranty that no number is dialed more than once. If a number has already been dialed log the record as duplicate in the status report file.
Explanation / Answer
Q1:ANS
import java.io.*;
private static void verifyDsRecordForSignerOf(final RRSIGRecord rec) throws IOException, DNSSECException {
final Name signer=rec.getSigner();
System.out.println(" Launch a query to find a RRset of type DS for zone: " + signer);
final Resolver res=newResolver();
final Record question=Record.newRecord(signer,Type.DS,DClass.IN);
final Message query=Message.newQuery(question);
final Message response=res.send(query);
System.out.println("Sent query and got response: " + response);
final RRset[] answer=response.getSectionRRsets(Section.ANSWER);
for ( final RRset set : answer) {
final Iterator<Record> rrIter=set.rrs();
System.out.println(" ;; DSset of the DNSKEYset");
while (rrIter.hasNext()) {
System.out.println(rrIter.next());
}
final Iterator<Record> sigIter=set.sigs();
System.out.println(" ;; RRSIG of the DSset of the DNSKEYset");
while (sigIter.hasNext()) {
final Record sigRec=sigIter.next();
System.out.println(sigRec);
if (sigIter.hasNext()) {
throw new IOException("We don't handle more than one RRSIGRecord for DS responses!!");
}
if (sigRec instanceof RRSIGRecord) {
final RRSIGRecord rr=(RRSIGRecord)sigRec;
System.out.println(";; Now, we want to validate the DS : Sucess of recursive call");
verifyZone(set,rr);
}
}
}
System.out.println(";; Failure of recursive call");
}
Description: In this program can be used to create priority class and call taking
sample code:
public class Customer {
private int id;
private String name;
public Customer(int i, String n){
this.id=i;
this.name=n;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
}
Q2 ANS:
import java.io.*;
protected DNSJavaNameService(){
String nameServers=System.getProperty(nsProperty);
String domain=System.getProperty(domainProperty);
String v6=System.getProperty(v6Property);
if (nameServers != null) {
StringTokenizer st=new StringTokenizer(nameServers,",");
String[] servers=new String[st.countTokens()];
int n=0; while (st.hasMoreTokens()) servers[n++]=st.nextToken();
try {
Resolver res=new ExtendedResolver(servers);
Lookup.setDefaultResolver(res);
}
catch ( UnknownHostException e) {
System.err.println("DNSJavaNameService: invalid " + nsProperty);
}
}
if (domain != null) { try { Lookup.setDefaultSearchPath(new String[]{domain});
}
catch ( TextParseException e) { System.err.println("DNSJavaNameService: invalid " + domainProperty);
}
}
if (v6 != null && v6.equalsIgnoreCase("true")) preferV6=true;
}
Description: This program can be using exception handling procedure to handle the exceptions it also shows the DNS invalid status on it can show this results based on records.
Q3 ANS:
import java.io.*;
public class PhoneNumber {
private String number; public PhoneNumber(String number) {
this.number = number;
}
public class PhoneNumber implements Comparable<PhoneNumber>{
private String countryCode;
private String areaCode;
private String subscriberNumber;
}
public String toString(){
return countrycode + " " + areaCode + " " + subscriberNumber;
public PickUpOrder(Date orderTime, String number) {
discount = .2; phoneNumber = number;
super.setOrderTime(orderTime);
System.out.println(phoneNumber)
}
}
OR other method :
import java.io.*;
public class Phones {
static final String DEFAULT_FILENAME = "phones.dat";
static PhoneDirectory directory; .
public static void main(String[] args) {
String fileName;
boolean done;
if (args.length == 0)
fileName = DEFAULT_FILENAME;
else
fileName = args[0];
readPhoneData(fileName);
done = false;
while (done == false) {
TextIO.putln();
TextIO.putln();
TextIO.putln("Select the operation you want to perform:");
TextIO.putln();
TextIO.putln(" 1. Add an entry to the directory");
TextIO.putln(" 2. Delete an entry from the directory");
TextIO.put("Enter the number of your choice: ");
int menuOption = TextIO.getlnInt();
switch (menuOption) {
case 1:
doAddEntry();
break;
case 2:
doDeleteEntry();
break;
static void doAddEntry() {
TextIO.putln(" Add entry for this name: ");
String name = TextIO.getln();
if (directory.numberFor(name) != null) {
TextIO.putln("That name is already in the directory.");
TextIO.putln("Use command number 4 to change the entry for " + name);
return;
}
TextIO.putln("What is the number for " + name + "? ");
String number = TextIO.getln();
directory.addNewEntry(name,number);
}
static void doDeleteEntry() {
TextIO.putln(" Delete the entry for this name: ");
String name = TextIO.getln();
if (directory.numberFor(name) == null)
TextIO.putln("There is not entry for " + name);
else {
directory.deleteEntry(name);
TextIO.putln("Entry duplicated.");
}
}
Description:
This method can be defined in two types the second method can be used to represent the data entry and duplication entry on the directory
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.