- #1
courtrigrad
- 1,236
- 2
Hello all
I have an exam tomorrow on Program Design and OOP Concepts. The majority of the exam will consist of questions that test your ability in distinguishing between terms. This will be the easy part. However, the more difficult portion of the test will contain a free response problem of multiple parts called a "design question."
Can you verify if I am doing this correctly:
Design a class to represent CAR. Instance variables stored about a car should be:
1. the make(Toyota, Ford)
2. mileage
3. the total gallons used
4. whether the car is an economy model, a moderately fuel efficient car or a gas guzzler.
5. miles per gallon
6. vehicle weight
Clients of this class should be able to access to find out the value of all attributes about a car. Clients should be able to modify instance variables 1, 2, 3, and 6. In writing the design, do not write any code. Just declare the instance variables and write the header for the methods.
My code:
I am not sure if I am doing this correctly. Do I put accessors and modifiers for each of the methods? How would I call the methods?
Any help is greatly appreciated
Thanks!
I have an exam tomorrow on Program Design and OOP Concepts. The majority of the exam will consist of questions that test your ability in distinguishing between terms. This will be the easy part. However, the more difficult portion of the test will contain a free response problem of multiple parts called a "design question."
Can you verify if I am doing this correctly:
Design a class to represent CAR. Instance variables stored about a car should be:
1. the make(Toyota, Ford)
2. mileage
3. the total gallons used
4. whether the car is an economy model, a moderately fuel efficient car or a gas guzzler.
5. miles per gallon
6. vehicle weight
Clients of this class should be able to access to find out the value of all attributes about a car. Clients should be able to modify instance variables 1, 2, 3, and 6. In writing the design, do not write any code. Just declare the instance variables and write the header for the methods.
My code:
Code:
public class Car {
private string make;
private double mileage;
private double totalgal;
private string classcar;
private double milespergal;
private double vehicleweight;
private double milespergallon;
public string getMake {
.
.
.
public double mileage {
.
.
.
I am not sure if I am doing this correctly. Do I put accessors and modifiers for each of the methods? How would I call the methods?
Any help is greatly appreciated
Thanks!
Last edited: