Can Someone Help Me With Inherritance
Hi I was hoping that someone might be able to help be with part of a Uni assignment I have.
One part of my assignment uses Inheritance and unfortunately I missed the lecture on this topic.
The problem goes like this:
I need to create the following 3 classes
Student class : Includes all common data from the UGStudent and GradStudent
UGStudent class : Creates a single UGStudent object. This class is descendant from Student.
GradStudent class : Creates a single GradStudent object. This class is descendant from Student.
I then have to read data in from a text file, which I can do.
Each line of the data file represents either an entry of UGStudent or GradStudent (each detail separated by ;).
The format for a UGStudent will be :
name, student id, address, contact phone number, subject number followed by list of marks (integer)
eg: Joe Bloggs;123456;1 First St, Sometown,9999;0401 234 567;9876;75;62;84
The format for a GradStudentwill be :
name, student id, address, contact phone number, previous degree, year of graduation, subject number followed by list of marks (integer)
eg: Bill Smith;111222;2 Second St, Sometown,9999;0499 876 543;B Sc;2000;5432;57;65;74
If someone could please help me on how to do this it would be greatly appreciated, or if they could point me to a solution to a similar problem for me to learn from that would be good too.
Jane
There are two separate issues here.
1. How to do the inheritance
2. How to create the instances
First the inheritance. You must define the three classes, where the specialized class extends the base class (Student). The base class has accessors for all the common data, and storage space for (well actually references to) the common data. The key to getting the derived classes store the common data in the base class is to use the super keyword in the derived constructor, which calls to the base class constructor.
No extra "business logic" has been included.
public abstract class Student {
private final String name;
protected Student(final String name, final ...) {
this.name = name;
public String getName() {
return name;
public class UgStudent extends Student {
public UgStudent(final String name, final ...) {
super (name, ...);
public class GradStudent extends Student {
private final String previousDegree;
public GradStudent(final String name, ..., final String previousDegree, ...) {
super (name, ...);
this.previousDegree = previousDegree;
public String getPreviousDegree() {
return previousDegree;
}The second bit is how to create instances of the two, when reading from a file. So, you will need something as follows:
final String name = ...; // read from file
final int studentNumber = ...; // read from file
final String addresss = ...; // read from file
final String phoneNumber = ...; // read from file
final String temp = ...; // read from file.
// this will either be the first entry in the list of
// marks or it will be the previous degree.
if (temp is a number) {
// we are dealing with an UgStudent
read the rest of the results and create an instance
} else {
// we are dealing with a GradStudent
read the year of qualification, the results and create an instance
}I have not shown how to read, nor have I shown how to determine if temp is a number. Finally, as the list of marks is probably a variable length list, I've not shown how to code this, nor capture it in the constructor. After all, some exercies must be left to the reader.
Similar Messages
-
I have an early 2011 MacBook Pro which has been running slow for a while. After looking at responses to similar problems I have downloaded and run EtreCheck. Please can someone help me with what it all means.
Thanks in advance.
EtreCheck version: 1.9.15 (52)
Report generated 19 September 2014 08:07:14 GMT+8
Hardware Information: ?
MacBook Pro (13-inch, Early 2011) (Verified)
MacBook Pro - model: MacBookPro8,1
1 2.3 GHz Intel Core i5 CPU: 2 cores
4 GB RAM
Video Information: ?
Intel HD Graphics 3000 - VRAM: 384 MB
Color LCD 1280 x 800
System Software: ?
OS X 10.9.4 (13E28) - Uptime: 0 days 0:4:29
Disk Information: ?
Hitachi HTS545032B9A302 disk0 : (320.07 GB)
S.M.A.R.T. Status: Verified
EFI (disk0s1) <not mounted>: 209.7 MB
Macintosh HD (disk0s2) / [Startup]: 319.21 GB (147 GB free)
Recovery HD (disk0s3) <not mounted>: 650 MB
MATSHITADVD-R UJ-898
USB Information: ?
Apple Inc. FaceTime HD Camera (Built-in)
Apple Inc. BRCM2070 Hub
Apple Inc. Bluetooth USB Host Controller
Apple Inc. Apple Internal Keyboard / Trackpad
Apple Computer, Inc. IR Receiver
Thunderbolt Information: ?
Apple Inc. thunderbolt_bus
Gatekeeper: ?
Mac App Store and identified developers
Kernel Extensions: ?
[not loaded] com.seagate.driver.PowSecDriverCore (5.2.4 - SDK 10.4) Support
[not loaded] com.seagate.driver.PowSecLeafDriver_10_4 (5.2.4 - SDK 10.4) Support
[not loaded] com.seagate.driver.PowSecLeafDriver_10_5 (5.2.4 - SDK 10.5) Support
[not loaded] com.seagate.driver.SeagateDriveIcons (5.2.4 - SDK 10.4) Support
[loaded] com.sophos.kext.sav (9.1.55 - SDK 10.7) Support
[loaded] com.sophos.nke.swi (9.1.50 - SDK 10.8) Support
Launch Daemons: ?
[loaded] com.adobe.fpsaud.plist Support
[loaded] com.microsoft.office.licensing.helper.plist Support
[running] com.sophos.autoupdate.plist Support
[running] com.sophos.configuration.plist Support
[running] com.sophos.intercheck.plist Support
[running] com.sophos.notification.plist Support
[running] com.sophos.scan.plist Support
[running] com.sophos.sxld.plist Support
[running] com.sophos.webd.plist Support
[running] com.trusteer.rooks.rooksd.plist Support
Launch Agents: ?
[loaded] com.divx.dms.agent.plist Support
[loaded] com.divx.update.agent.plist Support
[running] com.sophos.uiserver.plist Support
[running] com.trusteer.rapport.rapportd.plist Support
User Launch Agents: ?
[loaded] com.adobe.ARM.[...].plist Support
[running] com.amazon.music.plist Support
[loaded] com.google.keystone.agent.plist Support
[not loaded] jp.co.canon.Inkjet_Extended_Survey_Agent.plist Support
User Login Items: ?
iTunesHelper
TomTomHOMERunner
AdobeResourceSynchronizer
Dropbox
Internet Plug-ins: ?
FlashPlayer-10.6: Version: 15.0.0.152 - SDK 10.6 Support
DivX Web Player: Version: 3.2.1.977 - SDK 10.6 Support
AdobePDFViewerNPAPI: Version: 11.0.09 - SDK 10.6 Support
AdobePDFViewer: Version: 11.0.09 - SDK 10.6 Support
Flash Player: Version: 15.0.0.152 - SDK 10.6 Support
EPPEX Plugin: Version: 10.0 Support
Default Browser: Version: 537 - SDK 10.9
OVSHelper: Version: 1.1 Support
QuickTime Plugin: Version: 7.7.3
SharePointBrowserPlugin: Version: 14.4.4 - SDK 10.6 Support
iPhotoPhotocast: Version: 7.0 - SDK 10.7
Safari Extensions: ?
Ultimate
Audio Plug-ins: ?
BluetoothAudioPlugIn: Version: 1.0 - SDK 10.9
AirPlay: Version: 2.0 - SDK 10.9
AppleAVBAudio: Version: 203.2 - SDK 10.9
iSightAudio: Version: 7.7.3 - SDK 10.9
iTunes Plug-ins: ?
Quartz Composer Visualizer: Version: 1.4 - SDK 10.9
3rd Party Preference Panes: ?
Flash Player Support
Perian Support
Trusteer Endpoint Protection Support
Time Machine: ?
Skip System Files: NO
Auto backup: YES
Volumes being backed up:
Macintosh HD: Disk size: 297.29 GB Disk used: 160.38 GB
Destinations:
Data [Network] (Last used)
Total size: 2 TB
Total number of backups: 99
Oldest backup: 2012-04-20 17:05:32 +0000
Last backup: 2014-09-18 23:49:25 +0000
Size of backup disk: Excellent
Backup size 2 TB > (Disk size 297.29 GB X 3)
Time Machine details may not be accurate.
All volumes being backed up may not be listed.
Top Processes by CPU: ?
6% InterCheck
5% iCalExternalSync
3% WindowServer
2% CalendarAgent
2% SystemUIServer
Top Processes by Memory: ?
152 MB SophosScanD
147 MB InterCheck
106 MB SophosAntiVirus
66 MB Dropbox
57 MB com.apple.iTunesLibraryService
Virtual Memory Information: ?
161 MB Free RAM
1.55 GB Active RAM
1.41 GB Inactive RAM
902 MB Wired RAM
611 MB Page-ins
0 B Page-outsUninstall Trusteer software
http://www.trusteer.com/support/uninstalling-rapport-mac-os-x
Remove Sophos
https://discussions.apple.com/message/21069437#21069437 -
Can someone help me with an iCloud problem when I take a picture with my iPhone 4s it some of the times go to my ipad2 but mostly it doesn't can anyone help me out
I'm assuming you have Photo Stream set up of both devices. However, it seems many users are experiencing the same as you - my take is that streaming photos is not foolproof yet.
-
I have iOS 7. When I go to the itunes store on my ipod touch it gives me a blank screen with nothing on it. I restarted my ipod touch and it didn't work. Can someone help me with this?
- Reset the iOS device. Nothing will be lost
Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Go to Settings>iTunes and App stores and sign out and sign back in
- Reset all settings
Go to Settings > General > Reset and tap Reset All Settings.
All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
- Restore from backup. See:
iOS: How to back up
- Restore to factory settings/new iOS device. -
The calender on my iPhone 4 with iOS 6 no longer syncs with iCal 4.0.4 on my mac OS 10.6.8. However it is syncing with my iCloud account. Can someone help me with this?
FYI: It seems it was a network problem with my WinXP PC. After complete deletion and new installation of XP and iTunes my iPhone will be recognized correctly, Wifi synchronization works (mostly) fine.
-
Hi, can someone help me with my External HDD??? Please
Hi, Can someone help me with my Extenal HDD???
PleaseAfter you have all of the files from the External HDD you want to save, to format the HDD:
Open Launchpad
Open Utilities
Open Disk Utility
Select Hard Drive to format (the external HDD)
If you want to change partition size or number select Partition Table
Select number of partitions and adjust sizes if more than one
Name the partitions
Select the format from the pop-up menu (use Mac OS Extended (Journaled))
If it is not already selected, select GUID Partition Table
Click OK
Click Apply
And it should do the formatting for you.
Note: giving a name may come after the format selection, I sometimes get that out of order but it will lead you through the process. -
I have a problem with my blackberry 9360, I bought it last 2months, and now when I use video camera or camera I saw a red and blue line. Can someone help me with this issue?
Hello zukafu,
Welcome to the forums.
In this case we can try to reload the software on the BlackBerry® smartphone to make sure it is running the latest version and there are no issues with the OS.
Here is how to backup your BlackBerry smartphone http://bbry.lv/oPVWXc
Once you have backed up your BlackBerry smartphone please follow the link below to complete a clean reload of the BlackBerry smartphone software.
Link: http://www.blackberry.com/btsc/KB03621
Once completed test it and proceed with a selective restore, here is how to restore http://bbry.lv/qgQxLo
Thank you
-SR
Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)! -
i need help replacing a battery in my ipod nano 4th geneartion 16 gb can someone help me with step by step instructions or help me send it to apple store and replace and if so how?
Here is how to do it yourself.
http://www.youtube.com/watch?v=2h53otOBTsI
Here is how to send it to apple.
http://www.apple.com/support/ipod/service/battery/
Hope this helps! -
HI everybody i want to ask if you come me in help, i want to draw paths but when i use stroke options with pen or brush settings i loose quality when i zoom in , can someone help me with pen settings???
The work path is a vector object, and infinitely scalable, but when you stroke it, Photoshop lays pixels on a layer that follow the path. These pixels are raster based and can not be scaled without loosing quality. You do have options. If you want to make the raster layer bigger, transform the work path and stroke it again. Or work at a higher resolution in the first place.
Incidentally, you can't stroke a Path with the Pen, because it is a Vector based tool, and stroking is a raster based function. -
Hi! Can someone help me with repair service address for Palm TX?
Hi! Can someone help me with repair service address for Palm TX?
This question was solved.
View Solution.Good luck, and please let us know here how it works out for you. We love knowing of current resources who can help solve people's problems with these older devices.
smkranz
I am a volunteer, and not an HP employee.
Palm OS ∙ webOS ∙ Android -
Hi folks, can someone help me with my redemption code?
have a creative cloud id made last week.
but in order to install my products I have a redemption code needed but that I can't find anywhere. can someone help me???
Thank youI have a fully companies annual subscription of 69.99 a month.
but I can only download the 30-day trial versions.
and if I want to put on them completely firedamp should I enter a redemption code. could it be that the code later emailed word?
Met vriendelijke groet,
Dave Dros
Van: "hans-g." <[email protected]<mailto:[email protected]>>
Beantwoorden - Aan: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
Datum: dinsdag 21 oktober 2014 10:03
Aan: iMac <[email protected]<mailto:[email protected]>>
Onderwerp: Hi folks, can someone help me with my redemption code? have a creative cloud id made last week. but in order to install my products I have a redemption code needed but that I can't find anywhere. can someone help me??? Thank you
Hi folks, can someone help me with my redemption code? have a creative cloud id made last week. but in order to install my products I have a redemption code needed but that I can't find anywhere. can someone help me??? Thank you
created by hans-g.<https://forums.adobe.com/people/hans-g.> in Adobe Creative Cloud - View the full discussion<https://forums.adobe.com/message/6850359#6850359> -
I have followed the instructions to update Flash Player, the Installation Fails at about 90%, it says that there is an Application running (Safari) and it says to close all the apps. and start again ... but I already close all the Applications ... none is running ... can someone help me with this issue ??? Thanks ...
Dear Dominic
Brilliant reply. Simple English. Simple to follow instructions. And it worked immediately, first time.
Why couldn't the Apple and Adobe corporations get their programming right first time? We spend billions of UK pounds and US dollars with them. They reply with incompetent programming such as this, and arrogance to their customers in issuing faulty systems without doing the most rudimentary checks.
Anyway, I certainly shan't be buying another Apple as this is the most unreliable, most incomprehensible, most illogical and downright thoughtless shoddy piece of computer kit which I have ever owned. And all of it is rubbish ~ emails disappear, photos can't be organised properly, spreadsheets don't work, Pages is laborious… the list goes on and on...
But thanks to you Dominic, I have been able to load Adoble Flashj… maybe eyou should get a job at Apple, and set them all on the right course to how to work simply and correctly with customers.
Thanks again,
David -
After the OS 6 update my speaker does not work. Volume control on the side does not adjust the volume either. My music plays but no sound comes out. Can someone help me with this issue? I've tried rebooting my phone but still no sound comes out. I currently have the 4S.
try to activate and desactivate the airplne switch a couple of time
-
I download a game called warriors 3. I try to buy stuff inside, but it keeps saying your purchase could not be complete. Can someone help me with that?
You will need to contact iTunes support for purchase problems: https://getsupport.apple.com/Issues.action
-
My iphone 4S Black 16 GB with IOS 7.0.4 turns off randomly in low battery less than 15% and also when I am taking pictures from my front camera in low battery of 30%. This is happening very often. Can someone help here with advise? The phone is slightly more than 2 years bought from singapore I live in India
Either your battery is failing or your battery gauge needs to be recalibrated. Start by recalibrating:
When it shuts off charge for just a minute or two, then restart (hold HOME and SLEEP until an Apple logo appears). Deliberately run the battery down until the phone shuts off at 1%. If it shuts off above 1% repeat the above until you get to 1%. Then charge for 4 hours with the wall charger without using the phone. This process will recalibrate the battery gauge.
To prevent this from happening again about once a month run the battery all the way down to 1%, then continue until the phone shuts off. Apple recommends this in their battery help article, but they don't say why you should do it. The have some hokum about "keeping the electrons moving." Honestly! The iPad battery tip gives the correct reason.
If this does not resolve the problem you most likely need a new battery. If you are near an Apple store take the phone in and they can test the battery for you.
Maybe you are looking for
-
We are having problems with printing w-2's once they are generated through pu19. The spool generates a pdf file but we are unable to print the spool. I need to know if anyone is having the same issue and is there a solution or workaround. We have
-
Hi, I wanted to know if this is possible with order by clause and union. some how union messes up the ordering of the left part of the union statement. assume the data is as below in table tab1 c1 c2 4 1 4 2 5 1 5 2 7 1 7 2 8 3 9 4 the expected outpu
-
Hello, I made a WSDL client and now I've seen that java has a native client JAX-WS that I could of use. My original client knows how to use PKCS11 and how to set HTTP header vars(including basic HTTP authentication). I don't know how to translate PKC
-
Hi Is it possible to use the tables in WEBDB, which is created in Oracle 8i ? If yes, how to do that ? I am trying to create a "Frame Driver" in webdb using the table created in Oracle 8i. The Oracle home is different form 8i and webdb. I have writte
-
Hi All, I am seeking for help in accessing DI server on by website which is built on PHP. I have installed B1WS but am unable to figure out, how to work with b1WS in php. If anyone have some sample code or you have some other solution for this probl