Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 10th, 2013, 04:51 AM
SchoolJava SchoolJava is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 1 SchoolJava User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 52 sec
Reputation Power: 0
Homework - Cars Project (Help)

[IMG]Please can someone answer this question so i can compare mine.



Questions 1


Create a java class called Car.

The class needs to contain 4 variables
- ManType (The manufactures Name)
- Colour (A number to represent the colours)
- Length (The length of the car)
- Height (The height of the car)

Create getter and setter methods for all veriables. the setter method for ManType should ensure that the string passed as a parameter is converted to uppercase before being saved as the ManType.

Create a parameterised constructor. It should use the setter methods to set variables and not set the variables directly.

Create a toString() method. the method should return a String that follows the example below. "This is a White Audi of length 3.5m and height 1.5m" White,Audi,3.5 and 1.5 all taken from the variables.[/IMG]






[IMG]Question 2

Create a Scanner connecting to the text file Cars.txt

Read each line of the text file, and break into 4 variables. after checking vadility of variables, use the, to create a new car object, and store that into the Cars array CarA.

Create a parameterised method Count(String manType) which returns the number of cars in the array which match the manufacturers name.

Create a parameterised method Count(int colour) which returns the number of cars in the array which match the supplied colour.

Create a method called RandomPrint(). this method should check the number of cars in the array, and then select 10 random cars and print out their stats, by use of the toString() method of the car itself.

Create a method LongestCar(), which searches the array for the longest vehicle and prints out its details.

Create a method LowestCar(), which searches the array for the lowest vehicle and prints out its details.[/IMG]

Reply With Quote
  #2  
Old March 10th, 2013, 06:40 AM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,958 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 3 h 7 m 10 sec
Reputation Power: 345
If you are having problems with your code, post the code and your questions.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Homework - Cars Project (Help)

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap