Asm 01
Asm 01
Asm 01
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:
Do not pay attention to the real meaning of objects, variables, and their values in the questions below.
Write a class Supplier (in the default package of the NetBean) with the following information:
Supplier Where:
1
- int : id • Check validation (apply to constructors and
- String : name setters):
- String : address - check the name is not empty and length
- String : phone
from 5 to 50 characters. - if name is valid
- boolean: status
+Supplier () then status is true and otherwise
+Supplier - check the phone must be started with ‘0’
(id:int,name:String,address:String,phone:String) and length is 9 or 10 digits.
+getId(): int • Supplier () - default constructor (numeric
+getName(): String value is 0, string value is empty and boolean
+setName(): void
value is false)
+getAddress(): String
+setAddress(): void • Supplier(id:int,name:String, address:String,
+getPhone (): String phone: String) - constructor, which sets values
+setPhone(): void to id, name, address, phone )
+getStatus (): boolean • setName(value:String):void - If value invalid
+toString():String then set name to “no name”
• getName (): String – return Supplier name
with title case
• getAddress (): String – return address with
title case
• setPhone(value : String): void –If value is
invalid then set to “000.000.0000”
• Override toString() method to return a string
that contains all the information of the
Supplier: [id, name, address, phone, status]. If
status is true then print “Available” otherwise
“Unavailable”
1.Test Name
2.Test Phone
2
3.Test toString()
Enter Test Case No.(1 | 2 | 3):2
Enter phone:909123456
OUTPUT:
000.000.0000
-----------------------------------------------------
1.Test Name
2.Test Phone
3.Test toString()
Enter Test Case No.(1 | 2 | 3):2
Enter phone:09012345689
OUTPUT:
000.000.0000
1.Test Name
2.Test Phone
3.Test toString()
Enter Test Case No.(1 | 2 | 3):3
Enter id:1
Enter name:khai an company hcm city
Enter address:quan 1 - tpHCM
Enter phone:0908123456
OUTPUT:
1,Khai An Company Hcm City,Quan 1 - Tphcm,0908123456,Available
1.Test Name
2.Test Phone
3.Test toString()
Enter Test Case No.(1 | 2 | 3):3
Enter id:2
Enter name:khai
Enter address:quan 1, viet NAM
Enter phone:0908999888
OUTPUT:
2,No Name,Quan 1, Viet Nam,0908999888,Unavailable