Welcome! Log In Create A New Profile

Advanced

ICT2613

Posted by HTC 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar
Mac
Re: ICT2613
February 24, 2010 12:54PM
Re: ICT2613
February 24, 2010 03:15PM
sir i have a problem with question 5 assignment 2 must i use inheritance ,i'm not sure?
Re: ICT2613
February 25, 2010 10:04AM
No. We use inheritance when we want to extend another class functionality. If for example, we want to add a special kind of a pet. This pet can do anything that can be done by Pet (in question 4) and something extra that can not be done by Pet (in question 4)

Masombuka KT.
Re: ICT2613
March 01, 2010 04:13PM
can anyone by any chance help me up with the textbook i cann't find the textbook i ordered it and my order is still outstanding please people help me up.
avatar
Mac
Re: ICT2613
March 02, 2010 06:41AM
Please start new topics please! This topic is the only container for every post for the rest of the semester! The post here above could have been a new topic - Book.

If you have ordered it then you have found it - it just has not arrived yet? Why don't you take it up with the people you have ordered it through?
Re: ICT2613
March 02, 2010 10:14AM
I have been trying to run this code and i get two errors and one warning.The code is in the precribed book(java actually text book) chapter 7 program 7.1(declaration of instance method )
this is the code:
Language: Java
class EmployeeV3 { // Assume that no constructors are declared. // Field variables String firstName; String lastName; double hourlyRate; boolean gender; // false means male, true means female   // Instance methods   // Assign values to the field variables of an employee. void setState(String fName, String lName, double hRate, boolean genderValue) { firstName = fName; lastName = lName; hourlyRate = hRate; gender = genderValue; }   // Determines whether an employee is female. boolean isFemale() { return gender; }   // Computes the salary of an employee, based on the number of hours // worked during the week. double computeSalary(double numOfHours) { assert numOfHours = 0; "Number of hours must be >= 0"; double normalNumOfHours = 37.5; double weeklySalary = hourlyRate * normalNumOfHours; if (numOfHours > normalNumOfHours) { weeklySalary += 2.0 * hourlyRate * (numOfHours - normalNumOfHours); } return weeklySalary; }   // Prints the values in the field variables of an employee. void printState() { System.out.print("First name: " + firstName); System.out.print("\tLast name: " + lastName); System.out.printf("\tHourly rate: %.2f", hourlyRate); if (isFemale()) { System.out.println("\tGender: Female"); } else { System.out.println("\tGender: Male"); } } }
Can someone give me some light on what wrong am I doing and help with the correct code
avatar
Mac
Re: ICT2613
March 02, 2010 10:54AM
Compiling Files That Use Assertions

In order for the javac compiler to accept code containing assertions, you must use the -source 1.4 command-line option as in this example:

javac -source 1.4 MyClass.java

This flag is necessary so as not to cause source compatibility problems.

Compatibility With Existing Programs
The addition of the assert keyword to the Java programming language does not cause any problems with preexisting binaries (.class files). If you try to compile an application that uses assert as an identifier, however, you will receive a warning or error message. In order to ease the transition from a world where assert is a legal identifier to one where it isn't, the compiler supports two modes of operation in this release:
• source mode 1.3 (default) — the compiler accepts programs that use assert as an identifier, but issues warnings. In this mode, programs are not permitted to use the assert statement.
• source mode 1.4 — the compiler generates an error message if the program uses assert as an identifier. In this mode, programs are permitted to use the assert statement.
Unless you specifically request source mode 1.4 with the -source 1.4 flag, the compiler operates in source mode 1.3. If you forget to use this this flag, programs that use the new assert statement will not compile. Having the compiler use the old semantics as its default behavior (that is, allowing assert to be used as an identifier) was done for maximal source compatibility. Source mode 1.3 is likely to be phased out over time

Also, as Temba has pointed out:

It seems like this is a problem with 1.5. I was running 1.4 and I installed 1.6 (one in 2010 disk). There is no need to insert –source when compiling using ver 1.6 but you have to insert –ea (or –enableassertions ) to the running program otherwise it will ignore the assert statement. Also, if you use –source parameter, you get that print() error.
Re: ICT2613
March 02, 2010 01:46PM
can atleast someone put the questions(1 and 2) of the prescribed book on this forum?
avatar
Mac
Re: ICT2613
March 02, 2010 02:39PM
p.l.e.a.s.e. s.t.a.r.t. a. n.e.w. t.o.p.i.c. by clicking the New Topic link at the top. I have now closed this topic to force you to do that!
Sorry, you can't reply to this topic. It has been closed.