Getters would provide access to the attributes.

Assignment Help Computer Engineering
Reference no: EM1329344

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, and a subject code, 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.
- An accessor method called getDiscipline will return a string containing the first three characters of the 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.

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.
- 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.

Reference no: EM1329344

Questions Cloud

Elucidate the percentage rate of full employment : Elucidate the percentage rate of Full Employment and Inflation that that these two organizations try to keep as its target.
How to create a javascript program : Create a JavaScript program that declares and prints an array that contains at least 20 of your favorite songs. For each song, determine the best means for storing the year it was published.
Explain how can the abolition of cash fight inflation : Explain how can the abolition of cash fight inflation and reduce unemployment.
Impacts of integration of technology on customer relations : Impacts of the effective integration of technology upon customer relationships are also explored.
Getters would provide access to the attributes. : For this task you will make a Subject class, whose instances will represent the subjects for study at a university. A subject will have a name, just a String, and a subject code, that is a six-character String.
Strategic philanthropy : Discuss what strategic philanthropy is and why it is beneficial to organizations.
Finding present value of future amount : Given some amount to be received numerous years in future, if the interest rate increases, the present value of the future amount will be (pick the best answer)
Proper court to hear the case : The lawsuit is filed in the International Court of Justice (ICJ). Is this the proper court to hear this case? Why or why not?
Subsiquent policies would decrease demand-pull inflation : Among which of the subsiquent policies would decrease demand-pull inflation.

Reviews

Write a Review

Computer Engineering Questions & Answers

  More detail to be shown as a process is exploded

In data flow diagrams (DFDs), a process symbol can be referred to as a black box, becase the inputs, outputs, and general funcions of the process are known, but the underlying details and logic of the system are hidden.

  What type of procedures might a company put into place

What are some common steps and what type of procedures might a company put into place.

  Implementing model to check the vulnerability

Construct a simple threat model which explains the risk this represents: attacker(s), vulnerability, assets, attack vector, and the likelihood of occurrence, likely impact, and the plausible mitigations.

  Benefits of firewall

Write down a summary explaining the firewall you installed involve the benefits of firewall you selected.

  Sum of array elements

Provided an array of ints named x and an int variable named total which has already been described, write down some code which places sum of all the elements of the array x into total.

  Determining the area and perimeter of triangle

The class has attributes length and width, each of which defaults to 1. It has read-only properties which determine the Perimeter and Area of the rectangle.

  Calculating mod of the number

Consider the equation ax = b mod m, where x refers to the unknown and a, b and m are given. Display that this equation has either no solutions mod m, or d solutions mod m, where d = gcd (a, m); also, explain when each of these two cases holds.

  Advantages and disadvantages of moving this functionality

Many of the functions of an adapter could be performed in software that runs on the node's CPU.

  Define the concept of object orientation

decribe the concept of object orientation and Universal Modeling Language (UML) as used in computer programming.

  Benefits of the two computer programmers

A multinational corporation transfers the foreign employee to the United States on a L-1 visa. The foreign employee is a computer programmer, working alongside an American computer programmer doing the equal  work.

  Inheritance is a method in object-oriented programming

Inheritance is a method in object-oriented programming that you derive new classes from existing classes in your code.

  Transmitting image through raster scan

If we were to transmit this image utilizing the raster scan order, after 15 seconds how many rows of image will the user have received? To what fraction of the image does this correspond?

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