Asm 02
Asm 02
Asm 02
Duration: 70’
======================================================================
Software Requirements
• Netbean 8.2 or later, JDK 8 or later, Notepad, Command Prompt, WinRAR / WinZip with
Windows Explorer (File Explorer) on Windows 7 and above.
Instructions
• Step 1: Students download the given materials from LMS.
• Step 2: Students read questions and prepare answers in the given template.
• Step 3: Prepare to submit the answer:
o For each question (e.g., question Q1, Q2, Q3,…), please create two sub-folders: run
and src.
o Copy the *.jar file into the run folder, and the entire project source code file into the
src folder.
• Step 4: Submit a solution for each question:
o Create a folder named : RollNumber_FullName_ASM0x (x : 1, 2, or 3) that
contains folders (created Step 03 ) as the below figure:
Write a class Vehicle and a class Audi extending from Vehicle (i.e. Vehicle is a superclass and Audi is a
subclass) with the following information:
Vehicle Where:
-id: String • Check validation (apply to constructors and
-name: String setters):
-price: double
1
-quantity: int - check the id is not empty and format :
Vxxxxxx (x is digits). If value is invalid then
+Vehicle() set id to V000000
+Vehicle(id:String, name:String, price:double, - check the name is not empty and length
quantity:int) from 5 to 50 characters. If value is invalid
+getId():String then set name to “new vehicle”.
+setId(value:String):void
- check the price from 1 to 1.000.000. If value
+getName (): String
+setName(value:String):void invalid then set price to 1
+setPrice(value:double):void - check the quantity from 1 to 1.000. If value
+getPrice (): double invalid then set quantity to 1
+setQuantity(value:int):void • Vehicle() - default constructor (numeric value
+getQuantity (): int is 0, string value is empty)
+getSubTotal():double
• Vehicle(id:String, name:String, price:double,
+override toString():String
quantity:int): constructor, which sets values to
id, name, price, quantity )
• getName ():String – return name with title
case and each words is seperated by a space
• getSubTotal():double– return price * quantity.
• toString():String – return the string of format
:id, name, price, quantity, subTotal (the
price and subTotal are formatted with two
decimal places).
Where:
2
The program output might look something like this:
#Case 1: [2.0 marks]
1.Test Vehicle : toString()
2.Test Audi :toString()
Enter Test Case No.(1 | 2 ):1
Enter id:v010203
Enter name:audi v8
Enter price:5000
Enter quantity:2
OUTPUT:
V010203,Audi V8,5000.00,2,10000.00
-----------------------------------------------------
-----------------------------------------------------
3
Enter price:0
Enter quantity:0
Enter color:abc
Enter release year:1999
OUTPUT:
V000000,New Vehicle,Black,2022,1.00,1,1.00