[Solved] CSc20: Programming Concepts And Methodology II Lab 10

$25

File Name: CSc20:_Programming_Concepts_And_Methodology_II_Lab_10.zip
File Size: 499.26 KB

SKU: [Solved] CSc20: Programming Concepts And Methodology II Lab 10 Category: Tag:
5/5 - (1 vote)

Objective: The objective of this lab is to get you some experience in using generic classes, enums, foreach loops and the Java class library.

The Java class library: The Java Class Library is a set of dynamically loadable libraries that Java application programs can call at runtime. Like other standard code libraries, Java class library provides the programmer a well-known set of functions to perform common tasks, such as maintaining lists of items or performing complex string parsing. For Java 1.5 or later, some generic classes and generic interfaces are included in the Java class library. Examples:

import java.util.*;

public class Stack<E> extends Vector<E> { public Stack(); // constructor public Boolean empty(); public E peek(); public E pop(); public E push(E item);

}

public class LinkedList<E> extends AbstractSequentialList<E>

implements List<E>, Queue<E>, Cloneable, Serializable {

public LinkedList(); // constructor

public E getFirst(); public E removeFirst(); public void addLast(E item);

public Boolean isEmpty();

}

The programming assignment: In your lab07,

  1. Replace your stack of Object with the generic class Stack<E>.
  2. Replace your queue of Object with the generic class LinkedList<E>.
  3. Replace Post.toString() method with a for-each loop.
  4. Replace your exception classes with the following exception class.
  5. Remove all unnecessary type casts.

enum errorType { ExcessLeftParenthesis, ExcessRightParenthesis, ExcessOperator, ExcessOperand}; class infixException extends Exception { private errorType etype;

public infixException(errorType et) { // constructor

etype = et;

}

public String toString() {

return etype.name();

}

}

Reviews

There are no reviews yet.

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

Shopping Cart
[Solved] CSc20: Programming Concepts And Methodology II Lab 10
$25