Java Assignment: AddressName Class - OOP Implementation Details

Verified

Added on  2020/04/21

|2
|397
|42
Homework Assignment
AI Summary
This assignment focuses on the implementation of the AddressName class in Java, demonstrating object-oriented programming principles. The solution details the use of default and parameterized constructors, along with the Scanner class for user input. The assignment addresses the creation of a Java class to represent address information including house number, street name, town, county, and postcode. The solution also includes the use of the Scanner class to gather user inputs and implements input validation using if-else statements to ensure the program's robustness. The document explains how the Scanner class parses user inputs, particularly string values and primitive types. The solution demonstrates the integration of user input using the nextLine() method and ensures the reliability of the input data. The assignment aims to illustrate the practical application of OOP concepts in Java.
Document Page
Running head: OBJECT ORIENTED PROGRAMMING WITH JAVA
Object Oriented Programming with Java
Name of the Student
Name of the University
Authors note
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1OBJECT ORIENTED PROGRAMMING WITH JAVA
For this assignment I have selected the “AddressName” class from the given list of the
classes. For this class we have used default as well as parameterized constructors for the defined
class AddressName. This constructers are called inside from the main class while the
parameters for the AddressName class are collected from the user by using the scanner class. In
this application we have created a java AddressName class that contains details like of address
such as house number, a street name, a town, county and postcode. A constructor which takes no
parameter is defined as the default constructor for a class. It is also known as the no-argument
constructor. It is automatically generated by the compiler unless there is another constructor is
defined. It also initializes any uninitialized fields in the constructor to their default values as per
their requirement.
In order take inputs from the user we have used inbuilt Scanner class. The object of the
scanner class helps in breaking the input into multiple tokens. For this it uses delimiter which is
whitespace very often. The scanner class consist of numerous methods helpful for the programs
to get and parse various user inputted values (Mainly Primitive). This Scanner class is
extensively used in parsing of the text input for string values of the used variables in the
program. It also parses primitive types using regular expression defined in its definition. It also
extends Object class and on the other hand implements Iterator and Closeable interfaces in java.
The methods that help in parsing inputs are String next (), String nextLine(),float nextFloat() etc.
In our assignment we have used the Scanner next line () method in order to parse the user input.
In addition to this, to check the validity of the user input for the program we have also
used if else loop in order to notify the user that they may have skipped some step or to enter
some value for the program.
chevron_up_icon
1 out of 2
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]