-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarLabTester.java
More file actions
61 lines (47 loc) · 2.18 KB
/
Copy pathCarLabTester.java
File metadata and controls
61 lines (47 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//Hi this is Nancy
import java.util.*;
public class CarLabTester{
public static void main (String [] args){
//fist I'll assign everything using the actual parameters
//type (aka classname) variableName = new type (parameters);
//now use scanner
Scanner scan = new Scanner(System.in);
System.out.println("What year?");
int yearNum = scan.nextInt();
System.out.println("How many miles");
int milesNum = scan.nextInt();
System.out.println("What manufacturer?");
scan.nextLine();
String manufacturerStr = scan.nextLine();
System.out.println("What model?");
String modelStr = scan.nextLine();
CarLab car = new CarLab (yearNum, milesNum, manufacturerStr,
modelStr);
//dot operator is a .
//objectName.whateverMethodYouAreCalling (parameters)
System.out.println ("Year Manufactured: " + car.getYearManufactured());
System.out.println ("Miles Driven: " + car.getMilesDriven());
System.out.println ("Kilometers Driven: " + car.getKilometersDriven());
System.out.println ("Manufacturer Name: " + car.getManufacturerName());
System.out.println ("Model Name: " + car.getModelName());
System.out.println ("How many miles?");
//now I'll assign using setter methods
//setter method test
int a = scan.nextInt();
car.setMilesDriven(a);
System.out.println ("What year?");
int b = scan.nextInt();
car.setYearManufactured(b);
System.out.println ("What manufacturer?");
scan.nextLine();
String c = scan.nextLine();
car.setManufacturerName(c);
System.out.println ("What model?");
String d = scan.nextLine();
car.setModelName(d);
System.out.println ("Miles Driven: " + car.getMilesDriven());
System.out.println ("Year Manufactured: " + car.getYearManufactured());
System.out.println ("Manufacturer Name: " + car.getManufacturerName());
System.out.println ("Manufacturer Name: " + car.getModelName());
}
}