-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthor.java
More file actions
54 lines (45 loc) · 1.26 KB
/
Author.java
File metadata and controls
54 lines (45 loc) · 1.26 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
//Question 2: Create a Book with the following information.....
public class Author {
String auth;
Author(){
auth = "New";
}
}
class Book{
String name;
double price;
int qtyInStock;
Author obj = new Author();
Book( int q, double p, String n ){
qtyInStock = q;
price = p;
name = n;
}
public Author getObj() {
System.out.println(obj.auth);
return obj;
}
public int getQtyInStock() {
qtyInStock = 5;
return qtyInStock;
}
public double getPrice() {
price = 45.900;
return price;
}
public String getName() {
name = "Gaga";
return name;
}
public static void main(String[] args) {
Book obj1 = new Book(8,78.90,"Gigi");
System.out.println(obj1.price);
System.out.println(obj1.qtyInStock);
System.out.println(obj1.name);
System.out.println(".............................................");
System.out.println(obj1.getObj());
System.out.println(obj1.getName());
System.out.println(obj1.getPrice());
System.out.println(obj1.getQtyInStock());
}
}