Last active
May 9, 2017 05:42
-
-
Save dgadiraju/f047b6cc5daaa5a5b64a0302b0831075 to your computer and use it in GitHub Desktop.
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
package retail | |
/** | |
* Created by itversity on 08/05/17. | |
*/ | |
case class Department( | |
departmentId: Int, | |
departmentName: String | |
) | |
case class Category( | |
categoryId: Int, | |
categoryDepartmentId: Int, | |
categoryName: String | |
) | |
case class Product( | |
productId: Int, | |
productCategoryId: Int, | |
productName: String, | |
productDescription: String, | |
productPrice: Float, | |
productImage: String | |
) | |
case class Customer( | |
customerId: Int, | |
customerFname: String, | |
customerLname: String, | |
customerEmail: String, | |
customerPassword: String, | |
customerStreet: String, | |
customerCity: String, | |
customerState: String, | |
customerZipcode: String | |
) | |
case class Order( | |
orderId: Int, | |
orderDate: String, | |
orderCustomerId: Int, | |
orderStatus: String | |
) | |
case class OrderItem( | |
orderItemId: Int, | |
orderItemOrderId: Int, | |
orderItemProductId: Int, | |
orderItemQuantity: Int, | |
orderItemSubtotal: Float, | |
orderItemProductPrice: Float | |
) { | |
require( | |
orderItemSubtotal == orderItemQuantity * orderItemProductPrice, "Invalid orderItemSubtotal " + orderItemSubtotal | |
) | |
//Additional constructor | |
def this( | |
orderItemId: Int, | |
orderItemOrderId: Int, | |
orderItemProductId: Int, | |
orderItemQuantity: Int, | |
orderItemProductPrice: Float | |
) = { | |
//Invoking default constructor | |
this(orderItemId, | |
orderItemOrderId, | |
orderItemProductId, | |
orderItemQuantity, | |
orderItemQuantity * orderItemProductPrice, | |
orderItemProductPrice) | |
} | |
} | |
object retail { | |
def main(args: Array[String]) = { | |
val oi = new OrderItem(1, 1, 1, 2, 100, 50) | |
println(oi) | |
val ordItem = new OrderItem(2, 1, 3, 3, 50) | |
println(ordItem) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment