Created
April 3, 2014 05:25
-
-
Save JorgeOlvera/9948709 to your computer and use it in GitHub Desktop.
Author and Book classes, with their respective testing programs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Book { | |
private String name; | |
private Author author; | |
private double price; | |
private int qtyInStock = 0; | |
public Book(String name, Author author, double price){ | |
this.name = name; | |
this.author = author; | |
this.price = price; | |
} | |
public Book(String name, Author author, double price, int qtyInStock){ | |
this.name = name; | |
this.author = author; | |
this.price = price; | |
this.qtyInStock = qtyInStock; | |
} | |
public String getName(){ | |
return this.name; | |
} | |
public Author getAuthor(){ | |
return this.author; | |
} | |
public void setPrice(double price){ | |
this.price = price; | |
} | |
public int getQtyInStock(){ | |
return this.getQtyInStock; | |
} | |
public void setQtyInStock(int qtyInStock){ | |
this.qtyInStock = qtyInStock; | |
} | |
public String toString(){ | |
String title = (name + "by" + author.toString()); | |
return title; | |
} | |
public String getAuthorName(Book oneBook){ | |
String authorName = oneBook.getAuthor().getName(); | |
return authorName; | |
} | |
public String getAuthorEmail(Book oneBook){ | |
String authorEmail = oneBook.getAuthor().getEmail(); | |
return authorEmail; | |
} | |
public char getAuthorGender(Book oneBook){ | |
char authorGender = oneBook.getAuthor().getGender(); | |
return authorGender; | |
} | |
//dsda | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class testBook{ | |
public static void main (String [] args){ | |
Author authorOG = new author("Jorge Olvera", "[email protected]", 'm'); | |
Book oneBook = new Book(oneBook.getAuthor().getName(), oneBook.getAuthor.getEmail()); | |
System.out.println("Author: " + oneBook.getAuthorName(oneBook)); | |
System.out.println("Author's E-mail: " + oneBook.getAuthorEmail(oneBook)); | |
System.out.println("Gender: " + oneBook.getAuthorGender(oneBook)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment