Problem Solving Assignment 1

Test case due: Thursday, April 9th, 11:59pm

PSA1 due: Saturday, April 11th, 11:59pm



Breaking News:

This assignment requires you to design a class that rents a car by user input and by reading from a file.

There are 2 parts to this assignment. The first is a basic class that interacts with a tester, the second is a class that allows the Car class to interact with file input.

  1. Part 1: Car -- This class is where all of the getters/setters and manipulation methods will be. This is the definition of a rental car.

  2. Part 2: RentalAgency -- This class is used with Car to read data from a file and create and manipulate car objects based on the data in the file.

Details

This assignment requires a comment above each class which includes: Name, PID, 8B account, Email address, and a 2-3 sentence *high-level* description of what the class does.

You must also include a comment above each method that is a *high-level* description of what the method does.

You should also include inline comments throughout your code where necessary.

Use a multi-line comment (/* */).

You must observe an 80 column limit. No line of your program may be longer than the 80th column on the screen.

Car

Begin by copying this code.

Member variables:

There are 2 constructors for this class.

You will create accessing methods for your member variables.

You will create a toString method which takes no parameters and returns a String.

RentalAgency

Begin by copying this code into a file called RentalAgency.java. There is one conditional written for you, it is one of the more simple conditionals, but it might help to clear up confusion and get you started.

While we are often asked to write interactive software for users, we may build it and test it to run from a textfile of input. That is our boss or our colleagues or us ourself may define a bunch of test cases -- by giving the exact set of "input" that should be read in the program to test out certain cases. These serves as documentation of the kind of input the program expects and the test cases that have been run on it.

For Part B, write a class RentalAgency that takes input from a text file, not dynamically from user input. We've provided 2 sample .txt files for you to test with. However you need to create your own test file to submit along with the assignment. You will receive points for the quality of your test file (3pts, excellent, 2 pts OK, 1pt subpar, 0pts missing). In fact, we are requiring you to submit your test case early (by Tuesday 11:59pm week 2 -- using bundle). THEN, we suggest that you share your test cases on webboard and test your code with other people's test cases! There will be a prize awarded for the BEST test case submitted.

You may revise your code up until Thurs 11:59pm Week 2 -- when you will run bundle again. You can, at that point, turn in your favorite test case with the program. This can be one you created yourself, or it can be one that you modified from others. However, you must have a comment in the first line of your test case giving attribution to anyone else who contributed to your test case (or the ideas you used to create it).

This file will be very similar to RentACar.java, except it will read from a file. When writing Part A, you should have read through RentACar.java and understood what was going on. If you haven't done so, do so now. It is mostly the same, just reading from different mediums.

The purpose of Car[] cars is to hold up to 10 instances of cars. It will allow you to know which cars variables should be accessed.

After the BufferedReader is created, you should have a while loop that reads in one line of the text file at a time until the entire file has been read.

Each Iteration of the Loop: Should split the line read on a space, then save determine what needs to be donei, and declare a Car variable (should initialize to null, NOT default constructor).

If none of these cases get caught, then stop reading from the file and end normally.

All of this should be in a try-catch block. You should be catching any exception, printing an error message, and ending the program normally.

Testing your method

For Part A you MUST use our interactive tester, which can be found here. For Part B, you MUST use our test files, test1.txt and test2.txt, and you MUST create your own test file and submit it with the rest of your assignment. You should name it myTest2.txt.

The output should match the output below exactly. (You can use the output to determine default values, etc.)


test1.txt

RESULTS HERE

For the second tester, each block of code is a different test case. They are to check error messages. So after eash block, your program should end normally.

test2.txt

RESULTS HERE

Spacing does not necessarily have to be exactly the same, but the messages should be.

As mentioned above, these are NOT testing ALL cases, you will be expected to test more then what these test.



How to turnin your homework electronically

By Thursday, April 9th, 11:59pm:

When you are ready to turn in your homework, first open a terminal window by right clicking on the empty area of your computer's desktop (have to use lab computers or remotely connect from your home computer using SSH or Putty) and select "Open a New Terminal". Then, run bundlePSA1A from your PSA1A/ directory. Files are required to be submitted for PSA1A:

If you don't have this file present or have misspelled the name of one of this file, the bundle script will complain! Here you can see how you can run these commands:

-bash-2.05b$  cd ~/PSA1A 

-bash-2.05b$  bundlePSA1A 

Good; all required files are present:

	myTest1.txt

Do you want to go ahead and turnin these files? [y/n] y

OK.  Proceeding.


Performing turnin of approx. XXXX bytes
Copying to /home/linux/ieng6/cs8b/turnin.dest/cs8bxx.PSA1A
.
Done.
Total bytes written: XXXX
Please check to be sure that's reasonable.
Turnin successful.


Make sure the Turnin is successful, otherwise we won't receive your submission! . If you want to make changes after you've turned in your homework, make the changes and run bundlePSA1A again. The program will warn you that a "previously turned-in file exists" and ask if "you wish to over-write this existing file". Respond in the affirmative by typing y and pressing the Enter key.

By Saturday, April 11th, 11:59pm:(Note:myTest2.java is your favorite test case after seeing all other ones form your peers, or a modified version.)

When you are ready to turn in your homework, first open a terminal window by ri ght clicking on the empty area of your computer's desktop (have to uselab computers or remotely connect from your home computer using SSH or Putty)and select "Open a New Terminal". Then, run bundlePSA1B fro m your PSA1B/ directory. Files are required to be submitted for PSA1B:

If you don't have this file present or have misspelled the name of one of this file, the bundle script will complain! Here you can see how you can run these commands:

-bash-2.05b$  cd ~/PSA1B 

-bash-2.05b$  bundlePSA1B 

Good; all required files are present:

	Car.java
	RentalAgency.java
        myTest2.txt

Do you want to go ahead and turnin these files? [y/n] y

OK.  Proceeding.


Performing turnin of approx. XXXX bytes
Copying to /home/linux/ieng6/cs8b/turnin.dest/cs8bxx.PSA1B
.
Done.
Total bytes written: XXXX
Please check to be sure that's reasonable.
Turnin successful.


Make sure the Turnin is successful, otherwise we won't receive your submission! . If you want to make changes after you've turned in your homework, make the changes and run bundlePSA1B again. The program will warn you that a "previously turned-in file exists" and ask if "you wish to o ver-write this existing file". Respond in the affirmative by typing y and pressing the Enter key.