Create a subject class

Assignment Help JAVA Programming
Reference no: EM131565921

For this task you will create a Subject class, whose instances will represent the subjects for study at a university. A subject will have a name, just a String (for example, Programming in java 1), and a subject code (for example, ITC206), which is a six-character String. The first three characters of a subject code are alphabetic and the last three are numeric. The first three characters define the subject's discipline area. A subject code must be unique.

You will also write a TestSubject class to test the use of your Subject class. In particular this will maintain an array of subjects. In order to manage the uniqueness of the subject codes, your program will need to display information about existing subject codes as well as checking that any new subject code supplied by the user is not the same as any existing subject code.

The following state and functionality should be provided for the Subject class:

Two fields will hold the subject's name and the six-character subject code.

A constructor will allow a name and a new, validated subject code to be provided when a new subject is created.
Getters will provide access to the attributes i.e. subject name and subject code.

An accessor method called getDiscipline will return a string containing the first three characters of the subject code (for example ITC from ITC206 subject code).

Another accessor method called codeMatches will return a boolean value indicating if the subject's code matches the string argument provided. "Matches" is used here in the same sense as for the matches method of the String class.

A toString method will return a string containing the subject code and subject name.

To assist with managing subject codes and their uniqueness you will provide the Subject class with some class methods as follows:

An allDisciplines method will accept an array of Subject objects. It will return an array containing the different 3-character discipline codes represented in the array of subjects in alphabetically order.

A codesPerDiscipline method will accept an array of Subject objects and a 3-character discipline code. It will return an array containing the different subject codes represented in the array of subjects for the particular discipline.

An isValidCode method will accept a string that is a possible new subject code, and return a boolean indicating whether it satisfies the structural requirements for a subject code.

A codeExists method will accept an array of Subject objects and a possible new subject code. It will return a boolean indicating whether that code has already been allocated to one of the subjects in the array.

A sortDisciplines method will accept an array of Subjects objects. It will return the sorted array of subjects in alphabetically order (you may sort based on the subject code only).

Your TestSubject program will perform the following sequence of actions, using good design techniques such as in the appropriate use of methods:

An initial array of Subject objects will be created from any data in a file that was previously saved by the program. Then you need to read Subject objects from the file and store in appropriate array using your java program.

The user interaction will then proceed to allow the user to add one or more new subjects to the array. If the user wishes to add new subjects, the discipline areas of existing subjects should be displayed in alphabetically order. The user will then enter a discipline code to which the program will respond by displaying any existing subject codes in that discipline. This procedure simplifies the user's task of choosing subject codes that do not already exist, but does not prevent user mistake. Each subject code entered by the user should be checked. The user can enter any new subjects in that discipline (or indeed in other disciplines). The user should be given the choice of repeating the processing for other discipline areas.

When the user has finished adding subjects, and only if subjects have indeed been added, the program will overwrite the data file with the updated data.

Note:
You may use an ArrayList to implement an array if you prefer and it is appropriate.

Reference no: EM131565921

Questions Cloud

Create and describe each planned capital expenditure : Create and describe each planned capital expenditure. Prepare an executive summary along with a separate document showing the calculations.
Print a space after each seat : Given numRows and numCols, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat
Is that distinction practical and workable : What are the advantages and disadvantages of using such a dichotomy today as a way to advance that field of study? Support your case with examples.
Discuss the interrelationship of the cash flow statement : Discuss the interrelationship of the cash flow statement to the other financial statements
Create a subject class : create a Subject class, whose instances will represent the subjects for study at a university. A subject will have a name, just a String
The representation demonstrate non-normative sexuality : How does the representation demonstrate non-normative sexuality--in other words, does it challenge heteronormativity or gender norms?
Calculate the net benefit of outsourcing : Outsourcing (Make-or-Buy) Decision - Calculate the net benefit (cost) of outsourcing the electric motors from Mini Motor Company
Describe the role and purpose of statistics : Describe the role and purpose of statistics. Explain the primary types of statistics. Contrast a population and a sample.
Class that displays your favorite movie quote : Write, compile, and test a class that displays your favorite movie quote, the movie it comes from, the character who said it, and the year of the movie.

Reviews

Write a Review

JAVA Programming Questions & Answers

  How should ijvm be modified to make best use of instructions

On the full JVM machine, there are special 1-byte opcodes for loading locals 0 through 3 onto the stack instead of using the general ILOAD instruction. How should IJVM be modified to make the best use of these instructions?

  Advance programming hi i want two copies of the assignment

hi ltbrgti want two copies of the assignment me and my friend are doing same assignment. ltbrgtwe need both the

  Description of routes and services

Write a method for finding a journey from one station to another using an algorithm that is specified below in this handout.

  Create a japplet that contains a jlabel and jbutton

Create a JApplet that contains a JLabel and JButton -  create an HTML document to host the applet, set the Width to 450 and the Height to 200. Save as TestJChangeFont.html.

  Java threads

This is an introductory assignment on Java synchronization. You will use Java Threads while learning more about concurrency and achieving atomicity using Java’s inbuilt mechanisms.

  Palindrome is a sequence of char that reads backward forwrd

A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554, and 11611. Write an application called Palindrome.java that asks the user t..

  Purchasing type of mobile device

Mobile devices use touch screens to interact with the individual. Select a mobile device and identify three (3) important usability features that are important to you when purchasing this type of mobile device. Provide a rationale for your respons..

  Button to increase or decrease the number of the balls

Simulates a bouncing ball. Extend to allow mulitple balls. You can use the +I or -I button to increase or decrease the number of the balls and use teh Suspend and Resume buttoms to freeze the balls or resume bouncing. For each ball, assign a random c..

  Implement a training system for company directors

Object Oriented Software Engineering (COMP2003) - You have been asked to design and implement a training system for company directors. In the best tradition of economics, we shall start by making things up.

  Support for cloud-based strategies

In this course, you are introduced to general Windows Server concepts like active directory, group policy, security, networking and IIS, access control, and much more. Now that you understand the basic concepts, we will delve a little deeper and l..

  Program to convert a matrix to row echelon form in java

Program to convert a matrix to row echelon form in Java

  Simple java programming tests

The java coding that accepts a distance it kilometers, sends it to a method which converts it to miles, and then displays the result

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd