Skip to main content
UMass Collegiate M The University of Massachusetts Amherst
  • Visit
  • Apply
  • Give
  • Search UMass.edu
Manning College of Information & Computer Sciences

Main navigation

  • Academics

    Programs

    Undergraduate Programs Master's Programs Doctoral Program Graduate Certificate Programs

    Academic Support

    Advising Career Development Academic Policies Courses Scholarships and Fellowships
  • Research

    Research

    Research Areas Research Centers & Labs Undergraduate Research Opportunities

    Faculty & Researchers

    Faculty Directory Faculty Achievements

    Engage

    Research News Distinguished Lecturer Series Rising Stars in Computer Science Lecture Series
  • Community

    On-Campus

    Diversity and Inclusion Student Organizations Massenberg Summer STEM Program Awards Programs Senior Celebration

    External

    Alumni Support CICS
  • People
    Full A-Z Directory Faculty Staff
  • About

    Overview

    College Overview Leadership Our New Building

    News & Events

    News & Stories Events Calendar

    Connect

    Visiting CICS Contact Us Employment Offices & Services
  • Info For
    Current Undergraduate Students Current Graduate Students Faculty and Staff Newly Accepted Undergraduate Students

Material to Advance into CICS 210

Sample exercises students should be able to solve before taking CICS 210

Students who have enough prior programming experience to skip CICS 160 and move on to CICS 210 should be able to write Java solutions to programming tasks of the types listed below, which is the final assignment given to students in a previous semester of CICS 160:

1.  Implement class Queue, with the following methods: * 

  • dequeue() 
  • isEmpty() 
  • peek()

Your queue needs to be able to store any number of elements, expanding as needed. Because of the way objects of type Queue will be used in the rest of the assignment, your implementation of class Queue must allow its user to store any type of object inside of it, but only one type at a time, depending on how the Queue is declared, via Generics. For example, you should be able to declare a Queue of Integer objects, and a Queue of Car objects, and a Queue of Person objects, but a Queue of Car objects should NOT be able to store an Integer object, or a Person object.

2.  Implement a class called Car. This class will have three attributes: id, powerSource, and pricePerDay. id is of type int. powerSource is of type int, and will take values of 1, 2, or 3. 1 will be used to signify that the Car is a gasoline car. 2 will be used to signify that the car is a hybrid car. 3 will be used to signify that the car is an electric car. pricePerDay will store a floating point value. This class will have get and set methods for each of its attributes, and whatever constructor(s) you choose to implement. The name for the get and set methods will be getId, setId, getPowerSource, setPowerSource, getPricePerDay, and setPricePerDay.

3. Implement a class called CarFleet. This class will internally have three objects of type Queue, each of them storing Car objects. While these three queues all store Car objects, we will use them to store different types of cars. One queue will have only gasoline cars, one queue will have only hybrid cars, and one queue will have only electric cars.

Class CarFleet has a method called addCar. addCar takes as input an object of type Car, and places it in the appropriate queue inside carFleet based on the type of car that is being added (gasoline, hybrid, or electric). If the powerSource value does not correspond to any one of the carFleet queues, the method simply ignores the car and does not add it to any queue. addCar returns true when the car is added to one of the queues, and false otherwise.

Class CarFleet will have a method called processRequests. processRequests will receive as input a queue of integers. The integers inside this queue will indicate what type of vehicle customers are requesting. For example, a queue with values 1,2,3,2,2 means that customers are requesting a gasoline car, a hybrid car, an electric car, a hybrid car, and a hybrid car, in that order. The output of processRequests will be a list (not an array, not a CarFleet) of objects of type Car, satisfying the requests being placed by customers. These objects will come from the queues that class CarFleet is keeping internally. For example, with an input queue of 1,2,3,2,2 processRequests will return a list that has one car from the gasoline cars queue, one car from the hybrid cars queue, one car from the electric cars queue, and two cars from the hybrid cars queue, in that order. At any point that a car is placed in the list that processRequests will return, it is taken out of the internal queue it was in. Your code must only use valid queue operations while working with the queues that CarFleet keeps internally. If at any point the customers request list has a request that cannot be satisfied (for example, a customer is requesting a hybrid car, but the queue for hybrid cars is empty) a Car with an id of zero will be placed in the output list.

3. Write Junit tests for all methods in class Queue, class Car, and class carFleet.
Submit your work in six files: Car.java, CarTests.java, CarFleet.java, CarFleetTests.java, Queue.java, and QueueTests.java.

Sample of Work 

The following is a sample quiz from the first week of CICS 210, as well as an assignment from week 3 of CICS 210. This should give you a picture of the tasks which you will be supposed to accomplish when starting CICS 210 and help evaluate your level of preparation.

Sample Quiz

Sample Assignment

ZIP file

Local Navigation Links

AP Info for CS & Informatics Majors
Material to Advance from CICS 110 to CICS 160
Material to Advance into CICS 210

Site footer

Manning College of Information & Computer Sciences
  • Find us on Facebook
  • Find us on YouTube
  • Find us on LinkedIn
  • Find us on Instagram
  • Find us on Flickr
  • Find us on Bluesky Social
Address

140 Governors Dr
Amherst, MA 01003
United States

  • Visit CICS
  • Give
  • Contact Us
  • Employment
  • Events Calendar
  • Offices & Services

Info For

  • Current Undergraduate Students
  • Current Graduate Students
  • Faculty & Staff
  • Newly Accepted Undergraduate Students

Global footer

  • ©2025 University of Massachusetts Amherst
  • Site policies
  • Privacy
  • Non-discrimination notice
  • Accessibility
  • Terms of use