1 Project 12: Cars from File. This is an extension of Project 11, Car Class You may use the posted solution for Project 11 as a starting point for this.

Slides:



Advertisements
Similar presentations
Lecture 10 Flow of Control: Loops (Part 2) COMP1681 / SE15 Introduction to Programming.
Advertisements

The Line Class Suppose you are involved in the development of a large mathematical application, and this application needs an object to represent a Line.
1 Project 6: Tic Tac Toe. 2 Tic Tac Toe A Challange Project 10 Points extra credit on final grade OK to work in groups of 2 or 3.
1 Lab Session-3 CSIT221 Spring 2003 b Group Worksheet 3 Exercise (Demo Required) b No new lab demo will be assigned to allow you to focus on HW#1.
CS 206 Introduction to Computer Science II 01 / 23 / 2009 Instructor: Michael Eckmann.
1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.
1 Project 7: Huffman Code. 2 Extend the most recent version of the Huffman Code program to include decode information in the binary output file and use.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
1 Project 5: Median. 2 The median of a collection of numbers is the member for which there are an equal number less than or equal and greater than or.
1 Project 7: My Photo Album Graded Project. 2 Assignment Write a web app to permit users to upload and view photos. User can keep up to five photos on.
1 Project 4: XML Product Browser (Not Graded). Objectives This project is an exercise of the following knowledge and skills: Accessing and displaying.
1 Project 4: Vehicle Inventory. 2 Write a program to read a text file containing information about vehicles and output the information First in the order.
1 Project 3: Chomp (Not graded). 2 Project 3 The game of Chomp was described in a Math Trek column in Science News:
1 Project 5: New Venue. 2 New Venue Based on the posted New Venue scenario 077_Ticket_Booth_Scenarios.pdf.
1 Project 7: Northwind Traders Order Entry. 2 Northwind Order Entry Extend the Select Customer program from Project 6 to permit the user to enter orders.
11 Project 2 Towers of Hanoi. 22 Towers of Hanoi is a well known puzzle that can be very difficult to solve manually but can be programmed very easily.
CPSC 252 The Big Three Page 1 The “Big Three” Every class that has data members pointing to dynamically allocated memory must implement these three methods:
1 Project 5: Printing Address Labels. 2 Assignment Write a Windows forms program to display and print a set of address labels. Input from a csv file.
1 Project 3 The Kumquat Society Conference. 2 Conference Registration In this project you will write a program to handle a conference registration. The.
Project 3: Ticket Printer
1 COP 2510 Programming Concepts Spring credit hours Instructor:Dr. Rollins Turner ENB 343F Office Hours: MW 11:00 AM – 12:00.
© The McGraw-Hill Companies, 2006 Chapter 3 Iteration.
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
1 Project 3 String Methods. Project 3: String Methods Write a program to do the following string manipulations: Prompt the user to enter a phrase and.
1 Project 1: Tickets. 2 Class Ticket Write a definition for class Ticket. A Ticket object corresponds to a physical ticket for a stage show. Attributes.
A High Flying Overview CS139 – Fall 2006 How far we have come.
1 Project 2: Sorting Cats. Write a C++ console application to read a text file containing information about cats and output the information to the screen.
1 Project 4 Address Lookup. Project 4 Write an ASP.NET app that permits users to retrieve addresses from a potentially large list of addresses. There.
1 Project 3: Farey Sequences. 2 Farey Sequences Further details about Farey sequences, and more examples, can be found in the Wikipedia article:
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
11 Project 2 Temperature Conversion. 22 Project 2: Temperature Conversion Write an ASP.NET Web Forms app to convert temperatures from Fahrenheit to Celsius.
1 Project 5: Leap Years. 222 Leap Years Write a program that reads an integer value from the user representing a year and determines if the year is a.
1 Project 4: Computing Distance. 222 Computing Distance Write a program to compute the distance between two points. Recall that the distance between the.
1 Project 4: Palindrome Detector. 2 Assignment Write a C++ program that reads a line of text from the keyboard and reports to the user whether the text.
1 Project 4: Venue Sort. 2 This project is an exercise in Using C++ strings. Operator overloading. Text File Input.
1 Text File Input and Output. Objectives You will be able to Write text files from your Java programs. Read text files in your Java programs. 2.
1 Project 5 Eyeglass Rx User Control. Eyeglass Rx Earlier in the semester we looked at an eyeglass prescription as an example of an HTML table. 2.
1 Project 15: Animals Using Derived Classes and Inheritance.
A High Flying Overview CS139 – Fall 2010 How far we have come.
1 Project 6: New Venue. 2 New Venue Based on the posted New Venue scenario
1 Project 8: Tic Tac Toe. 2 Assignment Write an HTML and JavaScript page that pemits users to play Tic Tac Toe. Both players use a single browser. Alternating.
1 Project 7: Ticket_Booth_0 Using XML. 2 Ticket Booth 0 Base Level 0 of the real Ticket Booth program. Gets information for a single venue from an XML.
1 Project 6: Northwind Orders. 2 The Northwind Traders Database The Northwind Traders database was created by Microsoft for training and demonstration.
C++ Exceptions.
3.1 Fundamentals of algorithms
Exam 3 Information George Koutsogiannakis
Week 4 Object-Oriented Programming (1): Inheritance
Announcements 2nd homework is due this week Wednesday (October 18)
Review.
CS139 – Fall 2010 How far we have come
Some Tips for Using Eclipse
Java Programming with BlueJ
MSIS 670 Object-Oriented Software Engineering
Building Web Applications
In Class Programming BIS1523 – Lecture 11.
Introduction to Computer Programming
Programming in JavaScript
Constructors and Other Tools
INF 141: Information Retrieval
Tonga Institute of Higher Education
Programming in JavaScript
Programming in JavaScript
Programming in JavaScript
CS201 Fall 2016 George Koutsogiannakis
Java Programming with BlueJ Objectives
Running a Java Program using Blue Jay.
Learning Intention I will learn about the standard algorithm for input validation.
PHP-II.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2016 Section DA MW 4:05-5:20
CMSC 202 Exceptions 2nd Lecture.
Presentation transcript:

1 Project 12: Cars from File

This is an extension of Project 11, Car Class You may use the posted solution for Project 11 as a starting point for this project. You might also find the posted solution for Project 10 helpful. It is OK to copy code from any file posted on the class web site. 2

Assignment Add a constructor to the Car class from Project 11 that takes a file Scanner object as its only parameter. The file will consist of attributes of cars As read from the keyboard in Project 11 Let the new constructor read three lines from the file, using the scanner object passed by the caller, to get the attributes of a single car, and use those values to initialize a Car object: Make Model Year Remember that you will need to clear a blank line from the Scanner after reading the year as an integer. 3

Assignment Create a test driver called CarsFromFile. Accepts input from the keyboard for a file name. Creates a Scanner object for the file. Repeated invokes the new Car constructor, passing the Scanner object as the only parameter value. Adds the resulting Car object to an array. Upon reaching end of file, steps through the array of Cars and outputs the attributes of each car to the screen. 4

CarsFromFile.java You may assume that there will be no more than 100 cars in the file. If the file specified by the user does not exist, output an error message and let the user try again. 5

Implementation Tips As always, work in tiny steps. Start by adding a constructor to the Car class in the posted solution for Project 11: Car.java The new constructor should take a Scanner object as its only parameter. Use the Scanner object to read three lines from the file and initialize the Car member variables with the values from the file. Nothing else in Car.java should be changed. Get your modified Car.java to compile. 6

Step 2 Write a test driver to test the new constructor with just one car. Create a test input file with information for one car. Let the test driver Create a File object for your test input file, using a fixed file name. Create a Scanner object using the File object. Create a Car object using the new constructor that takes a Scanner as its parameter. Display the car using println. 7

Implementation Tips Step 3 Extend your test driver to work with an input file having an arbitrary number of cars. (No more than 100.) Still use a fixed (hard coded) file name. Add more cars to your test input file. Build an array of Car objects containing the Cars from the file. Upon reaching end of file, step through the array and output the attributes of each Car, using println(). 8

Implementation Tips Step 4 Add code to your test driver to get the file name from the user. Initially let the program crash if the file does not exist. Step 5 Add code to output an error message if the file specified by the user does not exist and let the user try again. 9

A Test File 10

Sample Run 11

12 Submission Put your Java source files into a folder and zip it. Submit your zipped folder via Canvas Assignments. Project is due by 11:59 PM Sunday, April 3 Sections 1 and 2 Monday, April 4 Sections 3 and 4 Recommendation: Do this project in your lab session or help session.

13 Ground Rules It is OK to discuss the project with other students BUT Do not share your code with other students. Before or after submitting the project. Do not copy any other student’s code. Or even look at it. Do not let anyone copy or examine your code.

Ground Rules Except for code posted on the class web site Do not copy code from the Internet or any other source (other than the textbook.) Do not ask for help on an Internet forum. If you need help, ask your instructor or a TA. Come to lab and help sessions. Write your own code.