Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Programming Assignment - Summer Semester 2015-

Purpose-

To provide students with the opportunity to apply the knowledge acquired and skills developed. These include understanding of primitive data types and the concept of collections (in the form of arrays) as well as structured programming including sequence, selection and repetition. 

Learning Objectives-

In the process of this assessment task you will:

  • Identify and use the correct syntax of a common programming language (Java);
  • Describe program functionality based on analysis of a given program;
  • Recall and use typical programming constructs to analyse, design and implement simple software solutions; and
  • Demonstrate debugging and testing skills whilst writing code.

Understanding and Enhancement of a Simple Menu Driven Program

Application Overview

For this assignment you have been provided with incomplete starter code that you must understand, modify and add to. The system provided simulates the collection, modification and reporting of game characters. The game characters have a unique id created in the program and have a number of attributes including a health rating and a power value. The system is run within the Eclipse IDE and provides a menu through the IDE console. The user must enter a pre-defined number of game characters before any of the other functionality can be used. At present, the following menu items are working:

  • Create your characters;
  • Display formatted information of all characters;
  • Display a particular character;
  • Display total legs and power for all characters; and
  • Empower your character.

One function listed on the menu is not working:

  • Display entered information of all characters

You must write the code for the missing function. 

Additionally, there are some changes required to the existing code. These changes are required to demonstrate the variety of ways of dealing with sequencing, selection and repetition and also demonstrate your capabilities for understanding and changing the code. 

PART A - Code Comprehension

The sample code provided in the GameCharacters.java class should be used to answer the following questions. Familiarise yourself with the operation of the application by running it and choosing the working options - 1, 3, 4, 5, 6:

1. Identify in the code the way in which users interact with the program. Identify the object and list the lines of code where the object is used to receive information from the user. Also list the lines of code where the program sends output to the user. 

2. What is the purpose of the "\t" in some of the literal Strings presented in the code?

3. How many game characters can be entered for this system? How many attributes does each character have? Identify the three lines of code where this information is established.

4. Currently, if the user enters an incorrect menu selection, what happens? Explain why the error message is displayed and what method and line of code is responsible and why.

5. The method menuSystem() is replaced with the code below. What would be shown for option 3 - display formatted information of all characters - if you had not yet entered any data (menu Selection ==1)? Where did the information displayed come from?

6. Explain in your own words what is happening on each line of the method createCharacterCode(int x).

7.  After entering the required number of game characters, choose option 3 to display formatted information of all characters and complete the following table of variable values after executing each line of the method decodeCharacterCode(int _code, int _row). Use a _row value of 1 and if a variable is not defined at any stage, use the text 'not defined':

8.  Now change the value of the FACTOR constant to 1000. Compile and run the application entering another set of game characters and choose option 3 to display the information. The code and studentID are incorrect on the report. What has gone wrong?

9.  In the createCharacterCode(int x) method, line 212 has the operation almostCharacterCode = almostCharacterCode * FACTOR; What would happen if you changed the "*" to a "/"? What primitive data type is almostCharacterCode and what would a more appropriate data type be if you changed the "*" to a "/"?

10. In the displayCharacterDetails(int _a) method a switch statement has been used to assist in assembling the String that lists the attributes of each character. The break keyword is used in this switch statement. What would happen if the break statement was removed after the first case (line 297)? You should discuss what generally happens with a switch statement when you remove the break and what actually happened here from an application perspective. What java error occurs? 

11. When entering characters, how many times is the createCharacterCode(int x) method executed? In the method itself, the condition if (almostCharacterCode == 0) exists. What other variable could have been used instead of  almostCharacterCode to achieve the same outcome? 

12. Explain the purpose of the boolean variable finished in the addPowerToCharacter () method and how it is used.

PART B - Programming Requirements

1. Provide the code for the displayAllCharactersRaw () method. You are expected to just list what has been entered by the user in "raw" form as well as the generated character code without any interpretation (i.e. the data as stored in the two dimensional array). In your solution you must use nested for loops and the constants for array dimensions. You must also only have one print statement in the outer loop detailing the attributes for the current character. This is done by using a String and concatenating to it. Look at the charAttrs variable in the displayCharacterDetails(int _a) method for an example of this.

2. Add any functionality required to allow two new power types to be added. Hint: you do not need to write any new lines of code. The power types and their values should be unique to each student. 

3. In the createCharacters () method, change the while loop for obtaining the studentID to a priming read while loop. Look at your lecture notes for week 4 for information on this.

4. In the displayCharacterDetails(int _a) method, replace the switch statement with a series of if/else if combinations to achieve the same functionality.

5. In the displayTotalLegsAndPower() method replace the for loop with a while loop. Look at your lecture notes from week 5 for information about this.

6. In the obtainCharacterAttribute(String _introText, String[] _typesText, int _min, int _max) method change the while loop to a do while loop.

PART C - Testing

An important part of verifying what you have done is testing. As per your lecture notes from week 5 you should consider:

  • Ensuring that the program is what the client is asking for (you have to be both client and programmer here);
  • Testing the design of the program to check that it meets the requirements;
  • Desk checking the code written; and
  • Testing the implementation of the code.

When testing, you should be able to distinguish between syntax, runtime and logic errors. Syntax errors are expected to be eliminated before submission (Eclipse IDE helps with this). Runtime and Logic errors are also expected to be eliminated if sufficient testing has occurred. 

You should at this early stage satisfy yourself and provide evidence that any changes you have made in ART B work as they should and have not had any adverse impact on other components. As a minimum you should provide evidence of the output of the system and its various functions before the changes and evidence of this after the changes. It is suggested that you make use of tables to display the data and testing.

Attachment:- Assignment.zip

Java, Programming

  • Category:- Java
  • Reference No.:- M91964112

Have any Question?


Related Questions in Java

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As